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

+1 vote

Hi everyone,

I have several Labels in different spots on screen, all members of a group and all sharing a script. There's a function in that script handling the transparency of all these Labels via Tween („modulate“), so I can have them all together fade in and out as I wish, which works fine.

However, trying to add another Tween („rect_position“) for tweaking their position puts all the Labels into that one position, overlapping each other, which seems like the logical consequence, as they all share the same script.

Is there any way to set a position-tween into that shared script while keeping each Label in their own original spot? I tried around with position: x and global_position but to no avail.

Godot version 3.3
in Engine by (525 points)

1 Answer

+1 vote
Best answer

Try setting initial_val as null.

$tween.interpolate_property(some_label, "rect_position", null, new_pos, time)
by (162 points)
selected by

Thanks for your suggestion.
Setting that "null" is quite interesting, it means, if I understand that right, that the object will move toward the goal-coordinates from wherever it is currently positioned! I didn't know that.

However, my problem remains, all my Labels mingle together in that one new spot... I wonder if could create a tween like "keep the x-position, only change y".

Just found a solution:

Correct, null means that the start will be at the position where the label is currently positioned.

And to change only the "y" position, write the following:

$tween.interpolate_property(some_label, "rect_position:y", null, new_y, time)

Yes, it's possible to tweak positions quite flexibly that way.
I, still the beginner, worried I'd have to throw some AnimationPlayer into the mix, but there's always some elegant solution out there... thanks again!

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.