Thanks for your attention.
Engine Version: 3.2.1 stable ver.
Background: For AnimationPlayer, I have created 8 animations, 4 directions for Idle, 4 directions for Run.
For AnimationTree, set to Active. I'm using StateMachine with BlendSpace2D, one for Idle, one for Run, and got them two-way connected, starting with Idle, and I've got blend set to that three dot one, and blend_position both set to (0,0).
I think I have checked the basics like if I've got AnimationPlayer set or the AnimationTreeRoot set to AnimationNodeStateMachine, Process_Mode set to physics because I am using physicsprocess(delta) in code.
Expect: Animation transition.
Result: Hit keyboard, sprite moves, but only plays the IdleDown(which has been set to autoplay on load) and RunDown animation(same direction), and jumps between them, like they are being played simultaneously. But even if there is no animation autoplay on load, the problem still stands, it's just that there will only be one animation played(RunDown), so the jumping issue disappears.
Here's the code.
const ACCELERATION = 500
const MAX_SPEED = 200
const FRICTION = 500
var velocity = Vector2.ZERO
onready var animationPlayer = $AnimationPlayer
onready var animationTree = $AnimationTree
onready var animationState = animationTree.get("parameters/playback")
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:
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
velocity = move_and_slide(velocity)
I have no idea, can somebody help me out?