Godot Version
4.3
Question
When i move forward in between two axes, my character moves a little bit to the left or right as well as the direction i intend to go. Any ideas why this could be happening? I tried using lerp instead of move_toward but that movement was extremely static and unrealistic. I want to have the player move only in the intended, forward direction. Any help would be appreciated.
Here is the script:
func _physics_process(delta):
if not is_on_floor():
velocity.y -= gravity \* delta
var input_dir = Input.get_vector(“left”, “right”, “forward”, “backward”)
var direction = (head.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = move\_toward(velocity.x, direction.x \* SPEED, 2) #starts movement smoothly, needs work
velocity.z = move\_toward(velocity.z, direction.z \* SPEED, 2)
else:
velocity.x = move\_toward(velocity.x, 0, 1) #stops movement smoothly
velocity.z = move\_toward(velocity.z, 0, 1)
move_and_slide()