How make the game yield until an animation is finished playing

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

Ok, so this is pretty straight forward. I’ve been having trouble trying to make the game wait until a animation is finished playing. I tried several things, including the yield function but I cannot make it work. Please, if anyone can help me out!

Below you can see the part of my code I’m working on

extends KinematicBody2D

var motion = Vector2()

func _ready():
   #var y = _physics_process(delta)
   print ("starting")

func _physics_process(delta):
if is_on_floor():
	if Input.is_action_just_pressed("ui_up"):
           yield(get_node("AnimatedSprite"), "finished") #<-Supposed to wait
           motion.y += JUMP_HEIGHT #makes player go up		
:bust_in_silhouette: Reply From: GameVisitor

You have to connect animation signal / finish event to a function of your choice as shown here

In the scene tree, select the animation object, then in the node signal select the animation finished event and connect it to a script.

voila !