[SOLVED] animation.play() dosen't work

please some one tell me how to play an animation in code

i have wrote animation.play(); but it dose not work and there is no error

so, i think there is no problem with the code. I added an animation component and my script the game object i want to animate what i am missing ?

Make sure your animation component has a default animation clip attached to it…
Also, if you want your object to play different animations as you need, you have to add those animations to your animation component ‘animations’ array and then you have to play them like:

animation.Play("animation_name");

Also,this:

animation.Play();

runs default clip only. So you need to make sure you have at least that clip attached to it.

if this solves your qusetion, mark it as solved.

PS: the ‘p’ in animation.Play() is capital.