So my problem is this, I have a script it allows you to crouch
{
if(Input.GetKeyDown(KeyCode.LeftControl))
{
// Plays the _____ animation - stops all other animations
animation.CrossFade("crouch");
}
}
and this one disables it when you let go
{
if(Input.GetKeyUp(KeyCode.LeftControl))
{
// Plays the _____ animation - stops all other animations
animation.CrossFade("standcustom");
}
}
and this one allows you to walk forward, while crouching
var ctrlDown : boolean = false;
function Update () {
if(Input.GetKey(KeyCode.LeftControl)) {
ctrlDown = true;
}
if(Input.GetKeyUp(KeyCode.LeftControl)) {
ctrlDown = false;
}
if(Input.GetKey(KeyCode.W)) {
if(ctrlDown == true) {
animation.CrossFade("crouchwalkforward");
}
else {
animation.CrossFade("walkcustom");
}
}
}
What works: When I hit control I crouch, I let go I un-crouch, that works great. When I hit control + W, I walk forward while crouching, that part works great. However When I let go of W, while holding control, I stand, although I am not actually standing, so the camera stays but the character moves up. If I change “else” to crouch, then he is always crouching when pressing “w” so that doesn’t work. Can someone help me?