Question by
leedrake1980 · Jun 29, 2017 at 06:30 AM ·
scripting probleminputcontroller
Crouch Script Issue
So, I'm coding a Crouch Script. I've found that when I release the crouch button, the collider returns to normal height, but the player collider is now halfway in the ground. How can I fix this? using UnityEngine;
public class Crouch : MonoBehaviour
{
CapsuleCollider characterCollider;
private void Start()
{
characterCollider = gameObject.GetComponent<CapsuleCollider> ();
}
void Update()
{
if (Input.GetKey(KeyCode.C))
{
characterCollider.height = 1.25f;
}
else
{
characterCollider.height = 2.72f;
}
}
}
Comment