Jump after the end of the animation

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

I can’t figure out how I can make my player jump only after that the “jumping” animation is finished. I tried a lot of things but my player now jump when he does the animation and i don’t want it.
Thank you for the help

:bust_in_silhouette: Reply From: supper_raptor

If you are using animation player, connect signal


so code would be

func _on_AnimationPlayer_animation_finished(anim_name):
    if anim_name == "jump":
        ready_to_jump = true

It doesn’t work, this is the part of my player(kinematicBody2D) code with the “jump”

func jump():

   if Input.is_action_pressed("jump") and is_on_floor():
   if ready_to_jump==true:

func _on_AnimatedSprite_animation_finished(anim_name):
   if anim_name=="jump":

It does the jump animation but it doesn’t jump , maybe i made a mistake on the signal but i don’t know

Matteo | 2020-04-06 08:51

It should be

if Input.is_action_pressed("jump") and is_on_floor() and ready_to_jump==true:

supper_raptor | 2020-04-06 11:36