I have been using a non-animated model in my game but my animator sent me a version of my character with a running animation. After importing this and running the game, I can see the run animation play on model (nested inside a ‘Player’ GameObject) but when I remove that animation and insert the animation onto the top-level ‘Player’ object (in order for it to be controlled by Player Animation script) it no longer seems to play. Why is this?
Here is the code :
void Start()
{
animation["AnimationName"].speed = 1;
animation.CrossFade("AnimationName");
animation["AnimationName"].wrapMode = WrapMode.Once;
}
in further you want to use it means use boolean variable, whenever it’ll true play the animation.
otherwise you can use
animation.Play("AnimationName");