So my current code for animation player is "laggy" and doesn't change direction very quickly. How can I change the code so if players do spam the left and right buttons the animation player will respond accordingly? Here is the sprite sheet for reference: Sprite Sheet. My animation player is: .3 seconds with .1 steps and keyframes at 0, 1, 2, 0 for left animation and 3, 4, 5, 3 for right animation
func _fixed_process(delta):
velocity.y += delta * GRAVITY
if (Input.is_action_pressed("ui_left")):
velocity.x = -WALK_SPEED
if not animPlayer.is_playing():
sprite.set_frame(0)
animPlayer.play("walk_left")
elif (Input.is_action_pressed("ui_right")):
velocity.x = WALK_SPEED
if not animPlayer.is_playing():
sprite.set_frame(4)
animPlayer.play("walk_right")
else:
velocity.x = 0