The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Hi , I have animated a 3D sprite to move upwards and then fade away with translation and modulate. This sprite is instanced a lot and I want each one to have a random offset so that they are all readable. As of now they almost layer onto of each other.
I do not know which value to change in my script.

My set up is animated
sprite 3D
richtext label (node with desired offset change i am thinking)
I have tried this but it did not work:
randomize() #new

var offset_x
    offset_x = randi()%100+1 #get random value between 1 -100 for offset?
    #$Viewport/RichTextLabel.position.x = offset_x # set off set?

maybe the property name is not offset_x, I do not know what it is.

in Engine by (58 points)

1 Answer

0 votes
Best answer

I think you're after something like:

var offset_x = randi()%100+1
$Viewport/RichTextLabel.rect_position.x += offset_x

Note, that's setting the x component of therect_position property of the RichTextLabel.

Also, the += there is adding the random offset value to the current position of the label. If, instead, you want to literally set the position of the label the to random value, change the += to just an =.

by (22,674 points)
selected by

thank you. this worked and did what i was looking for.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.