Ok, so I’m very new to unity. I have a background in 3d computer animation, with max and maya. My problem is, going through the 2d game tutorial found on this site, when I apply the scripts and techniques to my own models, nothing works right. My animations will not work when moving around the character. I started with a typical sphere with some simple squash animation on it for the walk. Im assuming the scripts wont work because the character has no bones? So I tried with a biped model as well, and the same thing happens. No animation, or the animation runs once then the character falls off the screen. is there a more detailed tutorial? Also, do you have to bake your animation in maya first before bringing the MA file into unity? I can’t find any clear info about how to setup your model/animations before bringing it into unity.
I’m pretty new to Unity, too, and I had some problems animating a character in Unity myself. I’ll try to give you a quick workflow overview:
You’ve got a character modelled in Maya/Max with bones and maybe some IK/FK handles set up and so on. Create your animations one after another on the time line and write down, what keyframes they start and end at. You’ll need that later.
When you´re done with everything, export your model and animations as an fbx file and be sure to check ‘bake animations’. IK is calculated realtime by Max/Maya and Unity can’t quite get that to work. I don’t know if there’s a way to let Unity calculate all that stuff, but from my experience Unity ignores IK by default. So baking your animations get’s rid of this.
When you’ve exported your model, copy the fbx file into your ‘assets’ folder, so it appears within your project panel. Click on it and scroll down to ‘(FBX Importer)’. There you can split your animations into single animation clips. Just check ‘Split Animations’ and click on the little plus sign to add as many animations as you created.
Type in the names, start and end keyframes, set the wrap mode and hit ‘Apply’.
Once done, you can simply drag&drop the animation clips to the ‘idle’, ‘walk’ etc slots of your character’s movement controller script in the inspector panel, if you’ve applied any (Third Person Controller from the standard asset for instance)
If you want to create your own movement controller script, remember to declare your animations as
public var animationname : AnimationClip;
right an the beginning of the script (take animationWalk and animationIdle for instance) so you can drag&drop your clips into the slots. To test them, simply add:
animations = GetComponent(Animation);
to your Awake() function and
if ( Input.GetAxes("Horizontal") || Input.GetAxes("Vertical") ){
animations.CrossFade(animationWalk.name);
} else {
animations.CrossFade(animationIdle.name);
}
to your Update() function. Then your walk animation only plays when you press the ‘walk’ buttons (by default: w, a, s, d or up, left, down, right)
When scripting, be aware of animations playing at the same time. You can prioritze certain animations by setting layers (higher priorities override lower)
I hope that helps a little