From 996e1e3b208197d5e07fdbcf44adea9cacd81914 Mon Sep 17 00:00:00 2001 From: Gregory Campbell Date: Sat, 4 Jan 2020 16:15:15 -0500 Subject: [PATCH] Fully functional and satisfactory acc/decc in movement (although a little slippery, might require more tweakign later on) --- Assets/Scripts/PlayerController.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 678ff90..15ad091 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -12,7 +12,6 @@ public class PlayerController : MonoBehaviour CharacterController characterController; CapsuleCollider capsule; - public float speed; public float maxSpeed; public float acceleration; public float friction; @@ -69,11 +68,11 @@ public class PlayerController : MonoBehaviour moveDirection = transform.TransformDirection(moveDirection); moveDirection = Vector3.ClampMagnitude(moveDirection, 1.0f); - if (jump > 2) + if (jump >= 2) { - if(maxSpeed > maxSpeedStore/3) + if(maxSpeed > maxSpeedStore/1.75f) { - maxSpeed -= acceleration*3; + maxSpeed -= acceleration; } } @@ -84,20 +83,22 @@ public class PlayerController : MonoBehaviour jump = 0; moveDirection.y = 0.0f; + if(maxSpeed > maxSpeedStore) + { + maxSpeed -= acceleration/10; + } + + if(maxSpeed < maxSpeedStore && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftControl)) + { + maxSpeed += acceleration; + } + if(Input.GetKey(KeyCode.LeftShift)) { if(maxSpeed > maxSpeedStore/2) { maxSpeed -= acceleration; } - } - - if(Input.GetKeyUp(KeyCode.LeftShift) || Input.GetKeyUp(KeyCode.LeftControl)) - { - while(maxSpeed < maxSpeedStore) - { - maxSpeed += acceleration; - } } if(Input.GetKey(KeyCode.LeftControl)) @@ -118,7 +119,7 @@ public class PlayerController : MonoBehaviour if(maxSpeed < maxSpeedStore*2) { - maxSpeed += acceleration; + maxSpeed += acceleration*2; } } else { @@ -132,7 +133,6 @@ public class PlayerController : MonoBehaviour } else { - //maxSpeed = maxSpeedStore; characterController.height = controllerHeight; capsule.height = capsuleHeight; transform.localScale = new Vector3(transform.localScale.x, transformHeight, transform.localScale.z);