0 votes

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
position += velocity * delta
position.x = clamp(position.x, 0, screensize.x)
position.y = clamp(position.y, 0, screensize.y)
in Engine by (12 points)

1 Answer

0 votes

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 :)

by (246 points)

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.

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.