Added implementation so that crawling in differentiated from sliding through current player movement

This commit is contained in:
Gregory Campbell
2019-12-06 22:34:57 -05:00
parent ba63ebf72b
commit 645395a43c
+13 -5
View File
@@ -67,19 +67,27 @@ public class PlayerController : MonoBehaviour
if(Input.GetKey(KeyCode.LeftControl))
{
characterController.height /= 2;
capsule.height /= 2;
transform.localScale = new Vector3(transform.localScale.x, transformHeight/2, transform.localScale.z);
if(Input.GetKeyDown(KeyCode.LeftControl))
{
startTime = Time.time;
}
moveDirection = (moveDirection.normalized * speed * 2);
characterController.height /= 2;
capsule.height /= 2;
transform.localScale = new Vector3(transform.localScale.x, transformHeight/2, transform.localScale.z);
if (startTime + oneSec <= Time.time)
if(characterController.velocity != new Vector3(0, 0, 0) && startTime + oneSec >= Time.time)
{
moveDirection = (moveDirection.normalized * speed * 2);
} else {
moveDirection = (moveDirection.normalized * speed/4);
}
} else {
moveDirection = moveDirection.normalized * speed;
characterController.height = controllerHeight;