I don’t know how to play an animation in a script. My script is:
if(transform.position.z <=125)
{
transform.Translate(0, 0, speed*Time.deltaTime);
Play.AnimationClip.runAnimation;
}
The bottom line was just guessing, so obviously it doesn’t work. Help me, somebody, anybody!
animation.Play(“runAnimation”);
or apart from the above anwers you could use CrossFade
hi,do you know maybe how can i make animation playing while i hold W? tnx
if (Input.GetKeyDown(KeyCode.W))
{
animation.Play("name");
}
else if(animation.IsPlaying("name"))
{
animation.Stop("name");
}
can ommit the else if section of if depending if you want animation to stop when w is not pressed
Also look into using animation states and using animation layers, these are very powerful tools in Unity’s animation arsenal. You shouldnt make a game without taking advantage of these features, they really make the difference between a game looking polished or amateur.
tnx for the reply,im working with the unity for a month now so im still in learning phase,ill check your tutorials i3D ,maybe i can learn something ,i will show you my work soon ,i want impressions 
Ok its working when i press W and its looping animation (simple rotation of the wheel) but it won’t stop when i release W 
set up a condition to stop playing the animation, or play another one when you let go of the W key
so if your pressing W, it plays the animation;
when you let go of W, it does something else