From 4b67ce701f50237b330d8a4388dbfcfc3fb41fd6 Mon Sep 17 00:00:00 2001 From: haitem Date: Sat, 29 Jan 2022 19:26:09 +0100 Subject: [PATCH] Start runing after click W --- Assets/Scripts/PlayerController.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index e194f0c..66ffb66 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -12,7 +12,7 @@ public class PlayerController : MonoBehaviour public float currentSpeed = 0f; private float modifier = 0.0f; Vector3 moveDirection = Vector3.zero; - bool canMove = true; + bool canMove = false; Rigidbody rb; float moveDirectionY; public bool isRunning = false; @@ -58,13 +58,15 @@ public class PlayerController : MonoBehaviour transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0); isRunning = Input.GetKey(KeyCode.LeftShift); - if (currentSpeed < minSpeed) + if (canMove && currentSpeed < minSpeed) { currentSpeed += 0.0005f; } - if (Input.GetAxis("Vertical") > 0 && currentSpeed < maxSpeed) - { + if (Input.GetAxis("Vertical") > 0 && currentSpeed < maxSpeed) { + if (!canMove) { + canMove = true; + } currentSpeed += 0.01f; } else if (Input.GetAxis("Vertical") < 0 && currentSpeed > minSpeed) { currentSpeed -= 0.01f;