From df08ad71b01d1bb21be3c64d583850ed652c7f2b Mon Sep 17 00:00:00 2001 From: Gregory Campbell Date: Fri, 7 Feb 2020 22:30:42 -0500 Subject: [PATCH] Made turning for the player much tighter and less slidey/icy --- Assets/Scenes/Floor Level.unity | 2 +- Assets/Scenes/Hub World.unity | 2 +- Assets/Scenes/Infinity Runner.unity | 2 +- Assets/Scenes/Waypoint Race.unity | 2 +- Assets/Scripts/PlayerController.cs | 8 ++++++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Assets/Scenes/Floor Level.unity b/Assets/Scenes/Floor Level.unity index ff9876c..3e5fe1c 100644 --- a/Assets/Scenes/Floor Level.unity +++ b/Assets/Scenes/Floor Level.unity @@ -2310,7 +2310,7 @@ MonoBehaviour: lives: 3 maxSpeed: 25 acceleration: 0.5 - friction: 0.1 + friction: 1 jumpHeight: 20 gravity: 5 rotationSpeed: 20 diff --git a/Assets/Scenes/Hub World.unity b/Assets/Scenes/Hub World.unity index 7cdcbc9..abcdeb5 100644 --- a/Assets/Scenes/Hub World.unity +++ b/Assets/Scenes/Hub World.unity @@ -3898,7 +3898,7 @@ MonoBehaviour: lives: 3 maxSpeed: 25 acceleration: 0.5 - friction: 0.1 + friction: 1 jumpHeight: 20 gravity: 5 rotationSpeed: 20 diff --git a/Assets/Scenes/Infinity Runner.unity b/Assets/Scenes/Infinity Runner.unity index c03c9e4..55e2d9a 100644 --- a/Assets/Scenes/Infinity Runner.unity +++ b/Assets/Scenes/Infinity Runner.unity @@ -2510,7 +2510,7 @@ MonoBehaviour: lives: 3 maxSpeed: 25 acceleration: 0.5 - friction: 0.1 + friction: 1 jumpHeight: 20 gravity: 5 rotationSpeed: 20 diff --git a/Assets/Scenes/Waypoint Race.unity b/Assets/Scenes/Waypoint Race.unity index 5aaf4d2..b76dfff 100644 --- a/Assets/Scenes/Waypoint Race.unity +++ b/Assets/Scenes/Waypoint Race.unity @@ -2246,7 +2246,7 @@ MonoBehaviour: lives: 3 maxSpeed: 25 acceleration: 0.5 - friction: 0.1 + friction: 1 jumpHeight: 20 gravity: 5 rotationSpeed: 20 diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 9d014fa..b3241a7 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -299,12 +299,16 @@ public class PlayerController : MonoBehaviour if((Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0) || (Input.GetButton("Stop") || Input.GetAxis("Stop") == 1.0f)){ //Remove or "lower" friction to add an 'ice' effect - velocity.x = Mathf.SmoothDamp(velocity.x, 0.0f, ref xVelocity, friction); - velocity.z = Mathf.SmoothDamp(velocity.z, 0.0f, ref zVelocity, friction); + velocity.x = Mathf.SmoothDamp(velocity.x, 0.0f, ref xVelocity, 0.1f); + velocity.z = Mathf.SmoothDamp(velocity.z, 0.0f, ref zVelocity, 0.1f); maxSpeed = 25; } + //Remove or "lower" friction to add an 'ice' effect + velocity.x = Mathf.SmoothDamp(velocity.x, 0.0f, ref xVelocity, friction); + velocity.z = Mathf.SmoothDamp(velocity.z, 0.0f, ref zVelocity, friction); + if(characterController.velocity == new Vector3(0, 0, 0)) { maxSpeed = maxSpeedStore;