From efb7dace84f248c14a5a431f9a907c486ac18e31 Mon Sep 17 00:00:00 2001 From: unfa Date: Sun, 14 Jun 2020 21:50:07 +0200 Subject: [PATCH 1/2] Stopped player sliding off of a slope. --- Player.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Player.gd b/Player.gd index fc95767..5f3be9b 100644 --- a/Player.gd +++ b/Player.gd @@ -64,7 +64,7 @@ remote func mouselook(rel): camera.rotation.x = clamp(camera.rotation.x-rel.y * MOUSE_SENSITIVITY, -PI/2, PI/2) func motion(delta): - self.move_and_slide(velocity.rotated(Vector3.UP, self.rotation.y) * delta, Vector3.UP) + self.move_and_slide(velocity.rotated(Vector3.UP, self.rotation.y) * delta, Vector3.UP, true) func _physics_process(delta): gravity() From 13491e7f0b162b9e1fb2d6bb2af6be2b1bcf4990 Mon Sep 17 00:00:00 2001 From: unfa Date: Sun, 14 Jun 2020 21:54:52 +0200 Subject: [PATCH 2/2] Fixed weird rotation inertia with mouselook. --- Player.gd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Player.gd b/Player.gd index 5f3be9b..bc3c715 100644 --- a/Player.gd +++ b/Player.gd @@ -1,7 +1,7 @@ extends KinematicBody -const GRAVITY = 9.8 -const JUMP_VELOCITY = 400 +const GRAVITY = 9.8 * 1.5 +const JUMP_VELOCITY = 600 const WALK_VELOCITY = 700 const AIR_CONTROL = 0.1 @@ -48,11 +48,11 @@ remote func walk(direction: Vector2): debug.text = "Interpolation: " + String(interpolation) debug.text += "\nwalkVelocity: " + String(walkVelocity) debug.text += "\ncurrentVelocity: " + String(currentVelocity) - + debug.text += "\nvelocity: " + String(velocity) debug.text += "\nis_on_floor(): " + String(is_on_floor()) - velocity.x = lerp(velocity.x, walkVelocity.y, interpolation) - velocity.z = lerp(velocity.z, - walkVelocity.x, interpolation) + velocity.x = lerp(velocity.x, walkVelocity.rotated(- self.rotation.y).y, interpolation) + velocity.z = lerp(velocity.z, - walkVelocity.rotated(- self.rotation.y).x, interpolation) remote func jump(): print("JUMP") @@ -64,7 +64,7 @@ remote func mouselook(rel): camera.rotation.x = clamp(camera.rotation.x-rel.y * MOUSE_SENSITIVITY, -PI/2, PI/2) func motion(delta): - self.move_and_slide(velocity.rotated(Vector3.UP, self.rotation.y) * delta, Vector3.UP, true) + self.move_and_slide(velocity * delta, Vector3.UP, true) func _physics_process(delta): gravity()