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))
|
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))
|
if(Input.GetKeyDown(KeyCode.LeftControl))
|
||||||
{
|
{
|
||||||
startTime = Time.time;
|
startTime = Time.time;
|
||||||
}
|
}
|
||||||
|
|
||||||
moveDirection = (moveDirection.normalized * speed * 2);
|
if(characterController.velocity != new Vector3(0, 0, 0) && startTime + oneSec >= Time.time)
|
||||||
characterController.height /= 2;
|
|
||||||
capsule.height /= 2;
|
|
||||||
transform.localScale = new Vector3(transform.localScale.x, transformHeight/2, transform.localScale.z);
|
|
||||||
if (startTime + oneSec <= Time.time)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
moveDirection = (moveDirection.normalized * speed * 2);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
moveDirection = (moveDirection.normalized * speed/4);
|
moveDirection = (moveDirection.normalized * speed/4);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
moveDirection = moveDirection.normalized * speed;
|
moveDirection = moveDirection.normalized * speed;
|
||||||
characterController.height = controllerHeight;
|
characterController.height = controllerHeight;
|
||||||
|
|||||||
Reference in New Issue
Block a user