- Home /
Unity Animation playing twice
I am trying to play a simple animation attached to the camera in the FPS player. And the problem is that the animation place twice without wait or anything like the player turnaround then turns back and turns around again then stops.
The script I am using is from outside and is as follows :
void Update(){
if(lit_1 == 1)
{
StartCoroutine(waitandturn());
}
}
IEnumerator waitandturn()
{
yield return new WaitForSeconds(3);
footsteps1 playastep = player_controller.GetComponent<footsteps1>();
playastep.isOnF = false; // Also I have a problem here.
camm.animation.Play("camera_turnaround");// the camera
yield return new WaitForSeconds(camm.animation["camera_turnaround"].length);
lit_1 = 2;
}
and I also have a footsteps script I am trying to stop it using the same code as above and its not working, I would like anyone could also tell me how to stop a sound. here is the script
Answer by Gurc · Apr 05, 2013 at 05:41 PM
Maybe you trigger animation twice. Did you try this? if(!camm.animation.isAnimationPlaying) { camm.animation.Play("camera_turnaround"); } Also you should check if you set lit_1=1 somewhere else
Your answer
![](https://koobas.hobune.stream/wayback/20220613095740im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can I make animations snap to a frame? 1 Answer
weapon sprint animation problem... 1 Answer
Strange animation glitch-mangled character 0 Answers
Material turns blue when changing the emission color smoothly 0 Answers
How to fix multiple character animations playing at the same time during a run animation? 1 Answer