Godot Version
Godot 4.4.1
Question
Help, idle animation plays even when i try to play a different animation
How do I stop that from happening?
The code I have is this:
var direction = Input.get_axis(“ui_left”, “ui_right”)
if direction == -1:
get_node(“AnimatedSprite2D”).flip_h = true
velocity.x = max(velocity.x - acc, -SPEED)
elif direction == 1:
get_node(“AnimatedSprite2D”).flip_h = false
velocity.x = min(velocity.x + acc, SPEED)
if Input.is_action_just_released(“ui_left”):
velocity.x = min(velocity.x - acc, SPEED)
elif Input.is_action_just_released(“ui_right”):
velocity.x = min(velocity.x + acc, SPEED)
if direction:
print(“true”)
if velocity.y== 0:
print(“pluh”)
$AnimationPlayer.play(“run loop”)
else:
print(“false”)
velocity.x = move_toward(velocity.x, 0, SPEED)
if velocity.y == 0:
$AnimationPlayer.play(“idle”)
if velocity.y > 0:
$AnimationPlayer.play(“Fall”)
move_and_slide()
If you see any other issues as well please point them out