Animated Sprite won't play through attack animation

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

Hey everyone. I’m really new to coding- I’ve been going crazy trying to figure this out, so if someone could please help me, I would greatly appreciate it. I am able to get my sprite to run around on the screen no problem- but the animation will keep playing without the anim.stop() (I’ve also tried anim.set_frame(0) )

But when I call this, the attack input will only play the 1 frame. I’ve tried using signals, but I don’t think I fully understand them, because that hasn’t fixed the issue for me. I got the idea to create an idle animation of sorts, but I am working with a sky view, so I either have to make an idle animation for each direction, or set a frame for each direction.

any guidance would be super helpful, thanks

func _process(delta):
var velocity = Vector2()
if Input.is_action_pressed("ui_up"):
	velocity.y -= 1
	$Link.play ("up")
	$Link.flip_h = velocity.x < 0
if Input.is_action_pressed("ui_down"):
	velocity.y += 1
	$Link.play ("down")
	$Link.flip_h = velocity.x < 0
if Input.is_action_pressed("ui_left"):
	velocity.x -= 1
	$Link.play ("right")
	$Link.flip_v = false
	$Link.flip_h = velocity.x < 0
if Input.is_action_pressed("ui_right"):
	velocity.x += 1
	$Link.play ("right")
if velocity.length() > 0:
	velocity = velocity.normalized() * speed
	$Link.play()
else:
	$Link.play("idle")
position += velocity * delta
position.x = clamp(position.x, 0, screensize.x)
position.y = clamp(position.y, 0, screensize.y)
:bust_in_silhouette: Reply From: nonomiyo

hello ! It’s not super clear to me, you’re talking about an attack input but I can’t see it in your code. Also, wouldn’t it be simpler for you to have 1 “idle” animation and 1 “walk” animation in your AnimationPlayer and just rotate Link depending on which direction key was last pressed ?

Did you see there’s actually a step by step video tutorial for making a zelda clone on godot 3 ?

hopefully that will help :slight_smile:

Yes! I actually found that like 10 minutes after I had posted this question. It does exactly what I’m trying to mimic with moving / attacking etc.

Thank you so much for the quick response, I really appreciate that.

Elginive | 2018-07-29 00:31