How to Check if Mecanim animation has finished?
Hey there, this question seemingly has been asked a lot but every link I've gone to has not provided me with any sort of answer to my current dilemma. Prior with regular Animation you could just check !isPlaying but now I can't seem to figure how how you can tell that an animation with mecanim has reached it's end.
I have all the basic FPS gameplay and animations right now I'm trying to add reloading. I want the reload animation to finish and then transition back into idle or walking depending on the current state. However, everything I've tried so far plays the whole animation but logically ends the reloading period early so you can begin shooting way before the animation is over.
The code is as follows:
if(currentAmmo < maxAmmo && extraAmmo >= maxAmmo - currentAmmo && Input.GetButtonDown("Reload") && !reloading)
{
anim.SetBool("isReloading", true);
reloading = true;
}
if (reloading)
{
if (anim.GetCurrentAnimatorStateInfo(0).IsName("Male_arms|walking"))
{
extraAmmo -= (maxAmmo - currentAmmo);
currentAmmo = maxAmmo;
anim.SetBool("isReloading", false);
anim.SetBool("isEmpty", false);
reloading = false;
}
}
This isn't correct as it stands and is just something I was trying out but I'm currently at a loss. It seems like it would be a simple solution but I'm hitting a wall currently.
Thanks in advance for any help!
Your answer
Follow this Question
Related Questions
fps script not working 1 Answer
Cannot attach game object to script. 0 Answers
HELP!! How to make my Mixamo Character sit on a CHAIR?? A* Pathfinding + Mixamo Animation 0 Answers
My Character won't jump 0 Answers
Help on how to code crouching? 0 Answers