0 votes

Hello, i've just started learning to use Godot Engine an I love it, but i have a problem:

I want to play an animation when press a key, in this case the "Z" key but i just get the first frame of the animation played only and there are 4 frames on it, this is my code:

func _process(delta):
if Input.is_key_pressed(KEY_Z):
    $spr_player.animation = "Charge"

i've tried different ways but always get only the first frame of the animation:

get_node("spr_player").play("Charge")

and

$spr_player.play("Charge")

I dont understand why doesn't work because this ones work without problem:

if move.x != 0:
    $spr_player.animation = "Run"
    $spr_player.flip_h = move.x < 0
elif move.y < 0:
    $spr_player.animation = "Jump"
elif move.y > 0:
    $spr_player.animation = "Down"
else:
    $spr_player.animation = "Standing"

Thnx a lot.

asked Jun 4 in Engine by checharor (26 points)

Where do you call get_node("spr_player").play("Charge")?

2 Answers

0 votes

Did you marke the loop checkbox for the animation?

answered Jun 4 by Becbunzen (156 points)
0 votes

I've already fix It.

I didn't know that the previous actions that I call affected the animation, I used the same code a few lines above and that did the trick, thnx a lot for your answers

answered Jun 4 by checharor (26 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 How to use this Q&A? before posting your first questions.