I dont know what ive done wrong ive done this before and i cant do it again it seems. So basically I'm doing some walking animations and i have it so its animated_sprite_2d.stop() and now it just doesn't play the animation at all. There is probably an easy fix but i just cant think today. See the image attached i haven't really explained it well
#Movement not working
1 messages · Page 1 of 1 (latest)
Your code looks fine. The issue could be any number of things. Does the animated sprite actually have an animation called "walk"? Do you have input actions created for "left" and "right"?
Oh, one thing i'm just noticing... you stop the animation on any other input. That will be triggered even by mouse movement Scratch that... this is happening in _process() or _physics_process(), correct?
It’s in _physics_process(delta)
It definitely has an action called left and right and definitely has a walk animation it works when I remove the animation_sprite_2d.stop but then it just never stops
Then i'm not sure why it's not working. You might try this code instead. This should also make it easier to add movement later:
var input: float = Input.get_axis("left", "right")
if is_zero_approximate(input):
animated_sprite_2d.stop()
elif input > 0.0:
animated_sprite_2d.play("walk")
animated_sprite_2d.flip_h = true
else:
animated_sprite_2d.play("walk")
animated_sprite_2d.flip_h = false
Ive tried that it gives the error Function "is_zero_approximate()" not found in base self.
Sorry, it should be is_zero_approx()