+2 votes

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 Engine by (14 points)

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

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories