fixed animation bug in sprite on diagonal walking

pull/1/head
Jaro Winkelhausen 2026-04-12 15:22:32 +02:00
parent ed15f87e6a
commit f8c78deed4
1 changed files with 11 additions and 12 deletions

View File

@ -7,19 +7,18 @@ func _physics_process(delta):
var direction = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
velocity = direction * speed
if direction == Vector2.ZERO:
animated_sprite_2d.play("idle")
elif abs(direction.x) >= abs(direction.y):
if direction.x < 0:
animated_sprite_2d.play("walk_left")
if direction.x > 0:
else:
animated_sprite_2d.play("walk_right")
else:
if direction.y < 0:
animated_sprite_2d.play("walk_up")
if direction.y > 0:
else:
animated_sprite_2d.play("walk_down")
if direction.x == 0 and direction.y == 0:
animated_sprite_2d.play("idle")
move_and_slide()