Godot Version
4.4.1
Question
Hello, maybe its nothing but when I tap my moving keys a certain amount of times, my character moves after I stop tapping the keys.
What I mean is that to test my movement Im rappidly tapping the WASD keys. But at a certain point when I stop pressing a move key (lets say A for left) the character moves a certain distance here is my movement code and how I get my direction vector
func get_move_axis() -> Vector2:
var inner_direction: Vector2 = Vector2.ZERO
if Input.is_action_pressed("move_right"):
inner_direction.x = 1
if Input.is_action_pressed("move_left"):
inner_direction.x = -1
if Input.is_action_pressed("move_up"):
inner_direction.y = -1
if Input.is_action_pressed("move_down"):
inner_direction.y = 1
return inner_direction.normalized()
func move() -> void:
velocity = Vector2.ZERO
#direction = Vector2(
#Input.get_axis("move_left","move_right"),
#Input.get_axis("move_up", "move_down")
#)
direction = get_move_axis()
if direction != Vector2.ZERO and !attacking:
velocity = direction * SPEED
last_input_direction = direction.normalized()
if abs(velocity.x) > abs(velocity.y):
if velocity.x > 0:
facing_direction = "right"
play_animation("walk-right")
else:
facing_direction = "left"
play_animation("walk-left")
elif abs(velocity.y) > abs(velocity.x):
if velocity.y > 0:
facing_direction = "down"
play_animation("walk-down")
else:
facing_direction = "up"
play_animation("walk-up")
else:
if velocity.x > 0:
play_animation("walk-right")
else:
play_animation("walk-left")
else:
if !attacking:
velocity = Vector2.ZERO
play_animation("idle")
move_and_slide()