Require help with Play method of animation !!!

I am making a gaming application on bowling. I have a problem related to playing a animation on trigger event of collision. Its a slider animation that slides all the bottle once the ball hits the bottle after waiting period of 5 seconds.

I am getting an error of “Animation Take 001 not found”. [Note : Take 001 is a slider animation] Also I have assigned this animation to a empty game object and unchecked this animation in inspector window since I want to play this animation only on collision event. Also I have assigned this empty game object as box collider ang checked it trigger event.

In the following code, I have created an invisible cube object that act as a collision event generator when the bowl hits this cube which is just placed ahead of bottles.

function OnTriggerEnter (myTrigger : Collider)
{

if(myTrigger.gameObject.name == “Cube”)
{
Debug.Log(“Ball Stopped !!!”);
yield WaitForSeconds(5);
Debug.Log(“After 5 seconds!!!”);
animation.Play(“Take 001”);

}

}

Can somebody help me sort out this issue.

I sometimes have trouble with yield so i most of the time use Invoke instead. That may be a quick fix.

if you don’t play with invoke alot (eg)

//---------------------------------------------------------------------//
function OnTriggerEnter (myTrigger : Collider){
  if(myTrigger.gameObject.name == "Cube") {
   Debug.Log("Ball Stopped !!!");
    Invoke("Play_0A",5);
  }
}
//--------------------------------------------------------------------//
function Play_0A() {
  animation.Play("Take 001");
}
//-------------------------------------------------------------------//

This may help :slight_smile:

Thanks for your effort. The script written by you also does not work. Getting the same error : Animation "“Take 001 not found”.