Normally would try and put some serious effort into trying to solve a problem by myself before turning to the UA community, but I’m dead tired. I have a crouch animation and when I’m not hitting the “S” key I want it to play the animation in reverse.
Animation Script
#pragma strict
var crouchCheck : boolean;
function Start () {
crouchCheck = false;
}
function Update ()
{
if(Input.GetKey(KeyCode.S) && !crouchCheck )
{
crouchCheck = true;
//animation["Crouch"].wrapMode = WrapMode.Once;
animation.Play("Crouch");
if(animation.IsPlaying("Crouch")) { print("Crouch Begins"); }
}
if(!Input.GetKey(KeyCode.S) && crouchCheck)
{
animation["Crouch"].speed = -1;
animation.Play("Crouch");
if(animation.IsPlaying("Crouch")) { print("Crouch ended"); }
crouchCheck = false;
}
}
When I hit “S”, it plays the Crouch animation perfectly and does the print. When I let go of crouch my player instantly jumps to a standing position instead of playing the animation in reverse and “Crouch ended” is printed. Then every time I hit “S” following the first semi-successful time doing the crouch(instant stand up), it doesn’t do the Crouch animation, but still prints “Crouch Begins” and prints “Crouch ended” upon release and doesn’t reverse the animation because it never did it in the first place. Am confused I? Yes.
-Crouch animation’s wrapmode is set to default