Page 1 of 1

Basic Mecanim Demo

PostPosted: Wed Oct 30, 2013 8:00 pm
by BenChang
Screen shot 2013-10-30 at 3.43.30 PM.png

In Maya, set up the animations as different sections in the timeline. For this example:

1-12 idle
13-38 walk
39-65 jump

Export as FBX, check Animation and Bake Animation.

In Unity, set the scale first in the Model tab of the import properties. If it comes in at .01 scale, set it to the correct scale. Do this first before setting up any of the Mecanim stuff.

In the Rig tab, set to Humanoid
Click the button to configure the avatar

Set up the links between the mecanim joint labels and the joint names in your rig (in this example, they're correct by default)

In the Animations tab on the model's properties, create the clips. set the start and end for each, and check the loop pose button for walks, idles, etc.

Create an Animator Controller (Assets->Create->Animator Controller)

Screen shot 2013-10-30 at 4.00.46 PM.png

Create states: idle, walk, jump

For each state, set the motion ( the animation clip )

create parameters: "walking" and "jumping" as bools.

Create transitions to go between the states, and set the conditions for each using the parameters

Create the script to set the parameters based on inputs:

Code: Select all
using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {

   private Animator animator;
   void Start () {
   void Update () {
      if (Input.GetKeyDown(KeyCode.A))
         animator.SetBool ("walking",true);   
      if (Input.GetKeyUp(KeyCode.A))
         animator.SetBool ("walking",false);   
      if (Input.GetKeyDown(KeyCode.Space))
      if (Input.GetKeyUp(KeyCode.Space))