How to make my character not switch side when finished pressing up or down button

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By youzar

Hey everyone,
I’m still new to Godot and I have been trying to create my first RPG game, but I have encountered some problems one of them is my character keep switching side when finished pressing the up or down button I’m currently using the Animationtree which stores the Idleleft and Idleright (i don’t have an animation for the up and down movement I want to stick with two movements) I have added the Idleleft on the left the Idleright on the right and for the up I added Idleleft and down Idleright I also have run animation and attack animation that works just fine. it’s only when I press the up button and my character is facing right he switches to the left side while moving up, and when he is facing the left side and I press the down button he switches to the right side while moving down

var input_vector = Vector2.ZERO
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
input_vector = input_vector.normalized()

if input_vector != Vector2.ZERO:
	animationtree.set("parameters/Idle/blend_position", input_vector)
	animationtree.set("parameters/Run/blend_position", input_vector)
	animationtree.set("parameters/Attack/blend_position", input_vector)
	animationstate.travel("Run")
	velocity = velocity.move_toward(input_vector * MAX_SPEEED, ACCELERATION * delta)
else:
	animationstate.travel("Idle")
	velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)

move()

hopefully, you find my question clear like I said I’m still new and I really appreciate any sort of help