Playing an animation with C#?

I haven’t been able to figure out how to do this with the scripting reference or with other Unity answers.

Right now I have deleted everything i have been testing on. I have a GameObject with an animator component and a transform component. (that makes 2 components)

I also have two animations in my asset folders: Idle and Run.

What do I need to do, and what should I write in the script I make to be able to play an animation?

I have tried attaching my animation to my GameObject and then tried using animation.Play(“animation”);, but that didn’t work. Maybe I messed up somewhere on the way - thats why I need help.

I had to rush my question, sorry for any spelling mistakes. Thanks for looking.

Lets see if i can help.

This is before Mecanim, so, maybe it needs some update.

First you need a correct rigged model with a skinned mesh.

The animation thing is BIG, so, take a break and dont panic.

First, think about layers and blending.

So, the main tools to code this:

dinosaur_anim.animation["EscapeAsFastAsYouCan"].layer = 3;	


That will do many tricks.
If you are in real trouble, read the docs.
Hey! The docs explains many many things.

Spelling is not that bad just use punctuation.
If you want to get more pro see the Mecanim Example with Teddy Bear.

If you know how to export from Blender with arroba, shoot. :wink: