+1 vote

Hy, i don't know how to change the animation back to idle when the attack anim has finished. Here is the code:

func physicsprocess(delta):

if Input.is_action_pressed("ui_right"):
    if is_on_floor():
elif Input.is_action_pressed("ui_left"):
    if is_on_floor():
elif is_on_floor():

if is_on_floor() and Input.is_action_just_pressed("ui_up"):

if is_on_floor() and Input.is_action_just_pressed("attack"):

if !is_on_floor():

in Engine by (29 points)

Did you solve the problem?

3 Answers

0 votes

AnimationPlayer has a 'finished' signal you can connect to. It passes the animation that finished. You can check that and kick off a different animation.

by (143 points)
0 votes

Create a variable that refers to the string name of the current animation. Connect the AnimatedSprite's animation_finished signal to a function:

$AnimatedSprite.connect("animation_finished", self, "name_of_function")

The function can check if the variable == "attack1" and then change it to "idle" if so. This requires replacing the string literals referring to the animations with the variable, which will be changed whenever you want to change animations.

by (533 points)
0 votes

Below the walk inputs you can place...

    motion.x = 0
    if is_on_floor():
by (103 points)
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 Frequently asked questions and 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.