# Problems with animation

Attention Topic was automatically imported from the old Question2Answer platform.

I don’t understand what’s going wrong. All animations for walking right, left, and up are playing normally. Idle right, idle left, idle up animations are also working correctly. However, the descent animation is not working. Instead, it maintains the ascent animation.

``````extends KinematicBody2D

onready var anim: AnimationPlayer = get_node("anim")
var velocity: Vector2
export(int) var speed = 200
var facingDir = Vector2()

func get_input():
velocity = Vector2()
if Input.is_action_pressed("ui_right"):
velocity.x += 1
facingDir = Vector2(1,0)
if Input.is_action_pressed("ui_left"):
velocity.x -= 1
facingDir = Vector2(-1,0)
if Input.is_action_pressed("ui_down"):
velocity.y += 1
facingDir = Vector2(0,1)
if Input.is_action_pressed("ui_up"):
velocity.y -= 1
facingDir = Vector2(0,-1)
velocity = velocity.normalized() * speed

func _physics_process(_delta):
get_input()
velocity = move_and_slide(velocity)

if velocity.x > 0:
play_animation("right")
elif velocity.x < 0:
play_animation("left")
elif velocity.y > 0:
play_animation("up")
elif velocity.y > 0:
play_animation("low")
elif facingDir.x == 1:
play_animation("idle_right")
elif facingDir.x == -1:
play_animation("idle_left")
elif facingDir.y == 1:
play_animation("idle_low")
elif facingDir.y == -1:
play_animation("idle_up")

func play_animation(anim_name):
if anim.current_animation != anim_name:
anim.play(anim_name)
``````

I don’t see any reference to the `ascent` or `descent` animations in the posted code…

jgodfrey | 2023-02-13 20:57

I think its these lines

``````elif velocity.y > 0:
play_animation("up")
elif velocity.y > 0:
play_animation("low")
``````

both of them are asking the same question i.e. if velocity.y is greater than 0. You should be asking if velocity.y < 0 to play up.

``````elif velocity.y < 0:
play_animation("up")
elif velocity.y > 0:
play_animation("low")
``````