Added implementation so that crawling in differentiated from sliding through current player movement
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user