I'm now using Godot 3.5 and my first person controller keeps sliding down slopes. This has nothing to do with the code for my gravity, because I know that the Is_on_floor function is working just fine. It's just that it slipes when it touches anything. Does anyone know how to fix this problem? Here is the movement code in it's entirety:
func _input(event):
if event is InputEventMouseMotion:
rotate_y(deg2rad(-event.relative.x * mouse_sensitivity))
head.rotate_x(deg2rad(-event.relative.y * mouse_sensitivity))
head.rotation.x = (clamp(head.rotation.x, deg2rad(-90),deg2rad(90)))
func _physics_process(delta):
direction = Vector3();var snap = Vector3.DOWN if not jumping else Vector3.ZERO
var gravity_resistance = get_floor_normal() if is_on_floor() else Vector3.UP
if not is_on_floor():
fall -= (gravity * gravity_resistance) * delta
move_and_slide_with_snap(fall,snap,Vector3.UP,true,1,deg2rad(50),false)
if Input.is_action_just_pressed("ui_cancel"):
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
if jumping and is_on_floor():
jumping = false
if Input.is_action_pressed("move_forward"):
direction -= transform.basis.z
elif Input.is_action_pressed("move_backward"):
direction += transform.basis.z
if Input.is_action_pressed("move_left"):
direction -= transform.basis.x
elif Input.is_action_pressed("move_right"):
direction += transform.basis.x
if Input.is_action_just_pressed("jump") and is_on_floor():
jumping = true;fall.y = jump
direction = direction.normalized()
velocity = velocity.linear_interpolate(direction * speed,acceleration * delta)
velocity = move_and_slide_with_snap(velocity,snap,Vector3.UP,true,1,deg2rad(45),false)