Basic Mecanim Demo

Basic Mecanim Demo

Postby BenChang » Wed Oct 30, 2013 8:00 pm

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))

Screen shot 2013-10-30 at 4.02.13 PM.png
Screen shot 2013-10-30 at 4.01.56 PM.png
Screen shot 2013-10-30 at 4.01.46 PM.png
Screen shot 2013-10-30 at 4.01.42 PM.png
(842.18 KiB) Downloaded 295 times
(555.52 KiB) Downloaded 264 times
User avatar
Posts: 176
Joined: Mon Jan 17, 2011 4:48 pm

Return to Game Development

Who is online

Users browsing this forum: No registered users and 2 guests