The walking animation isnt smooth at all

Godot Version

4.2.1

Question

the walking animation is a bit weird and here is the problem, for example you are walking left, but at the same time you press S to walk down and then let go of A, but the walking to the left animation is still playing. I have no idea where or what the problem is.
this is the code for animate and walking:

@onready var animationtree=$AnimationTree
@onready var state_machin= animationtree["parameters/playback"

enum {IDLE, RUN}
var state=IDLE
var blend_pos:Vector2=Vector2.ZERO
var blend_pos_path=[
	"parameters/idle/idle_bs2d/blend_position" ,
	"parameters/run/run_bs2d/blend_position"
]
var anime_state_key=[
	"idle",
	"run"
]



func move(delta):
	var input_vector = Input.get_vector("ui_left","ui_right","ui_up","ui_down")
	if input_vector==Vector2.ZERO:
		state= IDLE
		apply_friction(f*delta)
		
	else:
		state=RUN
		apply_move(input_vector*Accel*delta)
		blend_pos=input_vector
	move_and_slide()

func animate()->void:
	state_machin.travel(anime_state_key[state])
	animationtree.set(blend_pos_path[state],blend_pos

func _physics_process(delta):
	move(delta)
	animate()

and here is the 2D and animationTree :



Do you want to play corner (left down) walking animation? Or the idle animation is not playing, just the left walking animation playing?

No the idle animation plays accordingly.
let me show u in a pic

I wish i could have uploaded a video but i cant. the transition between animations doesnt work if you dont stop one. as i have said before, if you press A to walk left and without releasing the button, you press W or S, and then release the A button, the animation wont change.
the character animation has 4 directions not 8

try to print the input vector

what do you mean?

print(input_vector) #in the move function

ok… now what?

what showing in output? as when you press A and W/S

that was an example, it happens with every scenario, every button

I am not sure why its happening, have you tested this by moving the middle cursor

yeah nothing happened

All is working well? (The animation)

yeah, the only problem is the movement transition

You don’t have any animation in the 0,0 coordinate so it will try to get the closest one it finds which looks like it’s the right one.

Also, change the Blend mode to Discrete for 2D as you probably don’t want to blend the keyframes.

1 Like

you are a god sent