When I click on the player1,the timer should start and play the animation(its working fine).When the timer comes to zero the animation changes and play “DropBothFork01” animation.I have written the timer in update().But the problem is that when the timer stops the “DropBothFork01” animation is playing continuosly.(i know update()that calls continuosly).What is the solution for this? is it possible to do this without update?
public void Update(){
if(OnMouseDownnew)
{
timeLeft -= Time.deltaTime;
if (timeLeft <= 0.0f)
{
gamobjtxt3.text = "Time is over";
animation.Play("DropBothFork01");
}
else{
gamobjtxt3.text = "Time left = " + (int)timeLeft + " seconds";
}
}
}
void OnMouseDown () {
if(gameObject.name=="player1")
{
Camera.main.GetComponent<testscript>().animations();
OnMouseDownnew=true;
}}