- Home /
 
Animation won't play EVERY time it is called
I got a running game with the player running automatically and the only inputs for controls is shooting and jumping, they both work. The animation for shooting does work when I want it to, SOMETIMES. I don't know why, but it will occasionally not play the shooting animation when it's supposed to, sometimes it does that several times in a row and then will work again.
Here is the code that calls the animation for shooting
 void zombieShoot()
     {
         if(Input.GetMouseButtonDown(0))
             {
                 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                 RaycastHit hit;
                 
                 if(Physics.Raycast(ray, out hit))
                 {
                     if(hit.transform.tag == "zombieObstacle")
                     {
                         
                         dude.animation.Play("shoot");
                         gunFlash.Play();
                         audio.clip = gunShots[Random.Range(0,2)];
                         audio.Play();
                         
                         
                     }
                 }
             }
     }
 
              any help would be appreciated. I just came back to this project after being away a while.
Answer by 87morpheus · Jul 07, 2013 at 09:24 AM
Somewhere in your script, do you have something like gunTimer --?
Now that you mention it, that may have been the issue. I was using it to prevent from being able to shoot too fast, but now I have it set to only shoot when the zombie is clicked on...so I got rid of the timer.
I removed gunTimer from the script, no longer needed. Still same issue though
Your answer
 
             Follow this Question
Related Questions
Animation2D help! 1 Answer
Do animation rotations refuse to accept negative values? 2 Answers
Animation not looping 1 Answer
Create animation transitions via script. 0 Answers
The 'correct' way to deal with animations in a grid-based game? 1 Answer