- Home /
Mecanim how to make a the shooting animation fire rapidly
I'm trying to make an FPS with mecanim. I want to make it so my shooting animation can fires as fast as I can click. I'm using Input.GetButton("Fire1") instead of getbuttondown to test how fast it can shoot. It doesn't seem to be restarting the shooting animation fast enough, though. I want to know if I'm going about it the right way, and what the best way to make it go as fast as I can click is.
Here's my state machine: http://i.imgur.com/ylEvQa1.jpg And here's the script I'm currently using:
currentBaseState = anim.GetCurrentAnimatorStateInfo(0);
if(Input.GetButton("Fire1"))
{
anim.SetBool("Shot",true);
Shoot();
}
if(currentBaseState.nameHash == shootState)
{
anim.SetBool("Shot", false);
MuzzleFlashRenderer.enabled = false;
ShootLight.enabled = false;
}
Answer by Firedan1176 · Dec 15, 2014 at 12:10 AM
Under "Any State", set the "Can Transition To Self" to true.
Wow, thanks for this tip. This should really be added to docs and discussed more. This saved me so much trouble, I had found other ways of dealing with it, but all were extremely complicated and very prone to breaking when making changes to the controller. So far your answer is the only thing that is found from Google when searching this issue that immediately solves the issues without any complications!
Your answer
![](https://koobas.hobune.stream/wayback/20220613121348im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
AI shooting me and mecanim 1 Answer
how to do an action at a certain point of an animation in mecanim 1 Answer
Can I make animations snap to a frame? 1 Answer
What does Mecanim DO? 3 Answers
Mecanim starter pack - strafing motions 0 Answers