Question by
JarnoAkkerman · Feb 02, 2018 at 12:39 PM ·
movementcrouching
Making my crouching smooth
Hi there, I'm trying to make my crouch animation more smoothly. Now when i try to crouch, my camera goes smoothly down, but teleports back up. I watched other questions but none looked like mine.
void Update ()
{
if (Input.GetKeyDown("escape"))
{
Cursor.lockState = CursorLockMode.None;
}
CharacterController controller = gameObject.GetComponent<CharacterController> ();
if (Input.GetKeyDown(KeyCode.LeftControl))
{
if (!crouched)
{
characterCollider.height = 1.0f;
transform.localScale = new Vector3(1f, .6f, 1f);
crouched = true;
}
else
{
if (objectAbove == false)
{
characterCollider.height = 2.0f;
transform.localScale = new Vector3(1f, 1f, 1f);
crouched = false;
}
}
}
Comment