Play animation on unpause

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

Hi all,

I followed the pause tutorial and sample app and managed to create a popup pause menu easily. However I am unable to play an animation upon “unpausing” my game, using the following code :

func _on_btnunpause_pressed():
    	
    	$"Popup/lbl-anim".show()
    	$Popup/AnimationPlayer.play("anim_unpause")
    	
    	$"Popup".hide()
    	get_tree().set_pause(false)
    	pass # replace with function body

The result is having the game immediately un-paused (as if animation code is non-existent).

Thx

What is the Pause mode of the $Popup/AnimationPlayer node?

SASUPERNOVA | 2018-07-29 13:00

The pause mode is process (so is the mode of the label that displays a text for 2 seconds)

GameVisitor | 2018-07-29 15:00

It is possible that $"Popup".hide() gets called before your animation gets finished, which could cause your issue. Have you connected a method to the animation_finished slot of $Popup/AnimationPlayer?

SASUPERNOVA | 2018-07-29 22:13

:bust_in_silhouette: Reply From: code

or your animation runs on a _ready or _process func
reason:
the program will play new animation before u can see that ur animation is playing
i solve that problem using timer on my own project

:bust_in_silhouette: Reply From: GameVisitor

As @SASUPERNOVA mentioned, omitting the method:

_on_AnimationPlayer_animation_finished()

function was the issue.

It works great now :slight_smile:
Thx