auauauauauaua help
I decided to create an animation for 8 directions of movement using an animation tree. When starting the project, the character in the animation idle after walking is directed in the right direction — to where he was going. BUT when the character starts walking, it does not matter which direction the animation of walking will be directed only in 1 direction. : How to make the direction change when moving?
Blend_Position in idle and run = 0, 0
The animations are arranged as in guides, I checked everything
Here is an example of my code:
extends CharacterBody2D
@export var MAX_SPEED = 120
@export var ACCELERATION = 500
@export var FRICTION = 500
@onready var animationPlayer = $AnimationPlayer
@onready var animationTree = $AnimationTree
@onready var animationState = animationTree.get("parameters/playback")
func _physics_process(delta):
var velocity_vector = Vector2.ZERO
velocity_vector.x = Input.get_action_strength("right") - Input.get_action_strength("left")
velocity_vector.y = Input.get_action_strength("down") - Input.get_action_strength("up")
velocity_vector = velocity_vector.normalized()
if velocity_vector != Vector2.ZERO:
animationTree.set("parameters/Idle/blend_position", velocity)
animationTree.set("parameters/Run/blend_positon", velocity)
animationState.travel("Run")
velocity = velocity.move_toward(velocity_vector * MAX_SPEED, ACCELERATION * delta)
else:
animationState.travel("Idle")
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
move_and_slide()