Godot Version
4.4.1
Question
`Character doesn’t switch to other animation after stopping moving
func _physics_process(delta):
if current_id_path.is_empty():
return
if is_moving == false:
target_position = tile_map.map_to_local(current_id_path.front())
is_moving = true
global_position = global_position.move_toward(target_position, 1)
if global_position == target_position:
current_id_path.pop_front()
if current_id_path.is_empty() == false:
target_position = tile_map.map_to_local(current_id_path.front())
else:
is_moving = false
var walking_direction = target_position - global_position
var facing_direction
if (abs(walking_direction.x) > abs(walking_direction.y)):
if walking_direction.x > 0: #walking x axis
facing_direction = FacingDirection.RIGHT
animation_player.play("walking_right")
else:
facing_direction = FacingDirection.LEFT
animation_player.play("walking_left")
elif abs(walking_direction.y) > abs(walking_direction.x): #walking y axis
if walking_direction.y > 0:
facing_direction = FacingDirection.DOWN
animation_player.play("walking_down")
else:
facing_direction = FacingDirection.UP
animation_player.play("walking_up")
I’ve tried various code but it just doesn’t switch to the idle animation in which direction the character was moving to. Please help thanks
`