Animation clip does not play when initiated by code.

Hi I am trying to get my animation to play after a curtain amount of time but the animation doesn’t play when in game.
Here is my code (It is on my camera)

public var deathObject : GameObject;
public var song : AudioClip;
public var Wave1 : int; //240
public var Wave2 : int; //240

function Start () {
yield WaitForSeconds(Wave1); //Time Wave 1 Starts 
Destroy(deathObject);//Destroys object blocking path
audio.PlayOneShot(song); //Song that plays during wave 1

animation.Play("Church_Night");//<---------- Animation clip I want to play****

yield WaitForSeconds(Wave2); //Waits for wave 2

audio.PlayOneShot(song); //more audio
}

First, make sure the inspector view shows that the animation clip “Church_Night” (exact spelling and capitalization) is in the list of animations in your Animation component.

Then add some debugging to give you a better idea of what’s going on:

audio.PlayOneShot(song); //Song that plays during wave 1
Debug.Log("About to play Church_Night animation");
if (animation == null) Debug.LogError("No Animation component");
animation.Play("Church_Night");//<---------- Animation clip I want to play****
yield WaitForSeconds(Wave2); //Waits for wave 2
Debug.Log("Wave 1 finished. Waiting for wave 2");

If the console doesn’t show the “About to play…”, then you’re not getting to that point in the code.

If it shows “No animation component”, then the game object that this script is attached to doesn’t have an Animation component.