Animation won't play when changing scenes

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

I have two scenes, the second one has an animation that autoplay on load. When I run the second scene (the one with the animation) individually, by pressing F5, that animation autoplay normally. But, when I run the first scene and the code changes to the second scene (using change_scene_to), the animation won’t play.

Scene 1

func _on_ScoreTimer_timeout():
	score += 1
	$Scoreboard.text = str(score)
	if score == 5:

Scene 2

func _ready():
:bust_in_silhouette: Reply From: BakouKai

can you provide some sample code ?

What you can do, is include your animation in the _ready() function.
I do not know the kind of animation you want to play, but depending on the type, you sometimes have something to check in the inspector ( Playing → On)

I added the sample code to the question

gnunezandrade | 2021-05-01 15:31

Ok I see. Your code looks correct to me.
Maybe the Label is not ready when you call for the animation for some reasons…

Maybe we can try to call the animation differently ?
What about your emit a signal there (in the scene 2 _ready() ) and catch it in your label (add a small script and connect it to the signal, and make it only"TitleIn")

It is probably suboptimal though…

Is your AnimationPlayer under your Label node ?

BakouKai | 2021-05-01 17:03

Hey! Sorry for not getting back to you sooner. I figured out the problem, before changing scenes I pause the game, but I didn’t know that if I pause the first scene the second one would be paused as well. Just adding a ger.tree().paused = false fixed the problem. But thank you so much for the help!

gnunezandrade | 2021-05-06 11:37

ah well ^^ You are welcome :smiley:

BakouKai | 2021-05-06 12:10