From c15593f6b122b3f73d45269872856eeae41202d9 Mon Sep 17 00:00:00 2001 From: Gregory Campbell Date: Wed, 15 Jan 2020 18:44:22 -0500 Subject: [PATCH] Fixed infinite sliding issue --- Assets/Scripts/PlayerController.cs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index fddcdb4..1f7e1f7 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -169,18 +169,16 @@ public class PlayerController : MonoBehaviour if(Input.GetButtonDown("Crouch") || Input.GetAxis("Crouch") == 1.0f) { - if((Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)) + if((Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0) && !sliding) { - sliding = true; slideTime = Time.time; - } else { - sliding = false; - } + sliding = true; + } } - if(slideTime + halfSec >= Time.time && sliding == true) + if(slideTime + halfSec > Time.time) { - + if(maxSpeed < maxSpeedStore*2) { maxSpeed += acceleration*2; @@ -192,10 +190,10 @@ public class PlayerController : MonoBehaviour } } else { - + if(maxSpeed > maxSpeedStore/4) { - maxSpeed -= acceleration; + maxSpeed -= acceleration*2; } } @@ -234,8 +232,6 @@ public class PlayerController : MonoBehaviour if(dive == 1){ maxSpeed += 10; } - sliding = true; - slideTime = Time.time; } }