I am trying to make a 3D game with a first person character controller using Godot 3.5.3 and gdscript. Most of everything works except when I press and hold the move forward key on my keyboard, or any other movement key, while running the game, I move forward just a little, it waits a second, then moves forward and stops in quick succession with faster pauses between moving forward. Almost like how in a word processor, if you press and hold a key, it types it once, waits a second, then types it a bunch of times. Any help would be greatly appreciated. Thank You!
# Handle player movement
var velocity = Vector3()
if Input.is_action_pressed("move_forward"):
velocity.z -= speed
if Input.is_action_pressed("move_backward"):
velocity.z += speed
if Input.is_action_pressed("move_left"):
velocity.x -= speed
if Input.is_action_pressed("move_right"):
velocity.x += speed
velocity = velocity.rotated(Vector3.UP, rotation.y)
move_and_slide(velocity)
Oh I think I know what’s going on. As you said, similar event to the word processor hold probably starts firing after you hold down a button for a while.
You don’t want the movement logic in _input. Put it into _physics_process. (Conceptually you want to be always moving, not just when an input happens. The movement code executes every frame, but when no action is pressed, the player slows down or something.)
Looking around only when mouse moves is completely fine. Also probably do a type check on the event to separate mouse movements from clicks and key presses.