Why does my animationplayer don't play the animation?


What’s wrong with my code, that the animation doesn’t play. it prints that the current animation is playing. i removed all the reset tracks.
But it ether the zoom or the flip_h working

func bird_nest_animation():
	if Input.is_action_just_pressed("move_go_inside") && Gobal.in_nest_area == true:
		in_cutscene = true
		position.x = Gobal.nest_position
		Engine.time_scale = 0.5
		await is_on_floor
		print("in cutscene")
		print("animation: " + str(animation_player.current_animation))

You say it doesn’t do what you want, but what does it do? Does it do nothing, or does it skip the animation and do something else?

First thing that seems interesting to me is await is_on_floor. You can’t await on things that aren’t signals, so if this isn’t a signal that you’re emitting somewhere, then this won’t work.

The second thing to be careful of is that while the code after await runs later, the execution path that hits the await the first time returns immediately to keep the engine from locking up.

So if somewhere else in your code you have:

func _process(_delta):
    if something_something:

or something, then the execution path will go into bird_nest_animation and run jump, hit the await and immediately return, and then run change_scene in the parent context. Then, at some time later, the rest of the code in bird_nest_animation might run, but it doesn’t matter because we’ve already moved on.

If you take the jump and the await out of the code (or even just the await), does the animation play like you expect? If so, it’s probably that which is causing trouble.

Even if the await wasn’t the problem, though, play also doesn’t block, so I assume somewhere you’re looking for the finished_animation animation to end before you do whatever it is you do to get out of this cutscene?

Sorry if you already knew all this, and everything I’ve said is useless :sweat_smile: