- Home /
How do I restart and stop this animator
I am trying to make a shooter game and I have a gun that is constantly firing and I have made the animation stop however I need it to start for it to fire once when the left mouse is clicked and stop the animation until it is clicked again. Here is the code:
Animator ani;
// Use this for initialization
void Start () {
ani = GetComponent<Animator> ();
ani.Stop ();
}
(with out this the gun will constantly fire.) (Sorry I am a unity noob and am no good with code.)
Answer by bitstrider · Feb 22, 2016 at 08:13 PM
Have you tried using the parameters in your Animation Controller? You could these as conditions for transitioning in and our of your 'Shooting' state.
ani.SetBool("isShooting",true);
ani.SetBool("isShooting",false);
Of course you'll need to know how to set up the parameters and transitions from the Editor.
Your answer
Follow this Question
Related Questions
How to setup gun shot sound using only animator 0 Answers
Best way to play reload animations for a gun?? 1 Answer
Can I make animations snap to a frame? 1 Answer
Gun with animations 0 Answers
Gun is not shooting? Please Help! 3 Answers