Godot Version
Godot 4.4
Question
I have a game with a 3D first person player. When the player moves towards a wall at an angle, instead of sliding along it like normaly it slows down greatly and ‘grinds’ along the wall. If the angle gets too close to straight at the wall it just stops even though it should be sliding. I have another scene with the exact same movement script that works perfectly fine, so I have no clue why it isn’t working in this one.
Video of issue: https://drive.google.com/file/d/1kwSNDd8IR3ZfvAi5g9AAPhAZCek67Q5K/view?usp=sharing
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
# Get the input direction and handle the movement/deceleration.
var input_dir = Input.get_vector("left", "right", "forward", "backward")
var direction = (neck.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
anim_playing = true
else:
#velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.x = 0.0
#velocity.z = move_toward(velocity.z, 0, SPEED)
velocity.z = 0.0
# sprint functionality
if Input.is_action_pressed("sprint"):
SPEED = 3.0
$footstep_timer.wait_time = 0.38
else:
SPEED = 1.25
$footstep_timer.wait_time = 0.6
move_and_slide()