Godot Version
Godot 4.5.1
Question
How do I make my sprite stay facing the same direction while moving in y-axis?
So basically I have a sprite that only has two animation states for now which is idle and running in a top-down view with no animations facing up or down (kind of like a beat em up). For the most part it works alright; when I move in the x-axis the sprite behaves normally but when I move up or down the sprite for some reason flips to the left even if the sprite was facing right.
I’m using Blendspace1D to transition between idle and running and I suspect that might be a problem (probably should be using 2D instead) but I am also flipping the sprite from the animation player itself and not from the code which could also be an issue. I could probably just fix this if I just code everything directly into the script but I want to know how to make this work using animation trees although I am not against putting a few lines just to make it work.
The code seems pretty straight forward too it only has movement and a few lines for the animations. I’ll paste as much info below and thanks in advance to anyone who decides to help! ![]()

Example of what I mean.
extends CharacterBody2D
@onready var animation_tree: AnimationTree = $AnimationTree
@onready var sprite_2d: Sprite2D = $Sprite2D
var last_direction = Vector2.RIGHT
const SPEED = 100.0
func _ready() -> void:
animation_tree.active = true
func _physics_process(delta: float) -> void:
var input_vector = Input.get_vector("move_left", "move_right", "move_up","move_down")
print(input_vector)
if input_vector.length() > 0:
input_vector = input_vector.normalized()
velocity = input_vector * SPEED
move_and_slide()
if input_vector != Vector2.ZERO:
last_direction = input_vector
animation_tree["parameters/conditions/is_moving"] = true
animation_tree["parameters/conditions/not_moving"] = false
else:
animation_tree["parameters/conditions/is_moving"] = false
animation_tree["parameters/conditions/not_moving"] = true
animation_tree["parameters/Idle/blend_position"] = last_direction.x
animation_tree["parameters/Run/blend_position"] = last_direction.x


