How to properly animate a Control node with autoplay on load?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Paar

There is a change in the Godot 3.1 regarding Control nodes (for UI elements). Let’s say you have a title screen and you want to animate the name of the game, i.e. scroll it down from the top of the screen to the middle. When you create this animation through AnimationPlayer node with changing the rect position property, it looks ok in the editor but when you start the game the node is shifted to the side. It seems that right in the moment of the entire scene tree loads the precise position of all Control nodes is not known yet. Only after a while after the scene tree loads all these nodes are positioned properly and only after this is done you can animate them through rect position property.

I have tried to play the animation after signal resized() has been emitted and it worked fine. The problem is when you resize the game window - the signal gets emitted again and again and the animation starts again too. The solution is to add a check if the animation has been started already and start it only if it hasn’t been. To me this is rather ugly solution to otherwise simple thing. Do you have any idea how to play the animation without the code?

This sounds very specific, could you share a sample project?

flurick | 2019-03-15 23:54

It’s not specific. Just create empty scene, add Label node to it, assign dynamic font and set anchors to center of the screen. Then create an animation animating Label. rect_position property. I.e. move the Label out of the top edge of the screen and animate it so it moves down to the center of the screen. When you run to scene the Label won’t be centered.

Paar | 2019-03-17 07:51

1 Like

I’m wondering about this too. What I’m doing is animating the center container, which has position Vector2(0,0), with a tween.