Light explosion animation not working.

Hello Everyone,
I am trying to make a game in which there are 2 cars translating towards each other and i want to show an animation(Light explosion) on collision.
I have written the following script:

function OnCollisionEnter(collision:Collision)
{
 
    if(collision.gameObject.name == "car2")
    {
//Play animation
	animation.Play("Light explosion");
	
}
 
}

I have attached my script to game object.But animation doesn’t seem to work.Any idea???

1 Answer

1

Try this:

 var lightExplosion : AnimationClip;

Drag and drop the clip to the slot in the inspector. Then :

animation.clip = lightExplosion;
animation.Play();

Isn't the animation clip already present in animations?from where we need to drag and drop the animation?

From the Project view tab, wherever you created it originally in the Assets folder.

I haven't created any animation,I want the inbuilt animations.

There are none such. there's certainly not a built-in animation called "light explosion". You are just confused and you need to stop and RTFM before you go any further.