waiting for animation to finish

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

I try to make a punch animation but every time i press the button i set for punch the animation runs for a moment and immediately goes back the the default “stand” animation. here is the code:

extends KinematicBody2D

var movement = Vector2()
onready var anim = get_node("AnimatedSprite")

func _ready():
	pass


func _process(delta):
	if Input.is_action_just_pressed("p1_punch"):
		anim.play("punch")

	elif Input.is_action_pressed("ui_right"):
		movement.x = 3
		anim.play("walk")
	
	else:
		movement.x = 0

		anim.play("stand")

	move_and_collide(movement)

In the animation player, click on the button “Animation Looping”, an icon that looks like “recycle”. This will make the animation repeat endless.

Alex Pires | 2019-02-23 18:18