trigger mecanim animator

hello All
I have a character with an animator attached playing an idle animation
I simply want to trigger another animation in the same animator window

I’ve been searching these forums but it seems accessing animations in the animator still evades me…

Here is my non working script:

function Update ()


   if (Input.GetButtonDown("Fire1")) //check to see if the left mouse was pushed.


     animation.Play ("180Turn"); // if pushed play the animation listed within the quotation marks.

    //add multiple animations by copying and pasting this code (below for else if) and changing 

    //the animation and button.

      else if (Input.GetButtonDown("Fire2")) //check to see if the right mouse was pushed.


      animation.CrossFade ("almostSlip"); // if pushed play the animation listed within the quotation marks.



   else // if NOT just play the idle animation.

     animation.CrossFade ("Idle_Ready");


Thanks for your help !


The new animation system does not work as the legacy one. Generally speaking, you don’t need to call CrossFade and Play functions on animations anymore. What you need is to set the animation’s state machine accordingly.

For each animation, you will have a state in mecanim describing that animation. Then, when each state are set correctly, you’ll need to set transitions from one to another. A transition is triggered whenever its conditions are true.

Your conditions usually are simple checks from basic Unity types (bool, float, int, Vector3) and that’s those variables taht need to bet set in script, not the actual transitions.

For example :

animator.SetBool ("IsFiring", Input.GetMouseButton (0));

then set your transitions between animations with the variables you define inside mecanim.

If it’s not clear, you should look online for a quick tutorial about mecanim. You basically need to stop thinking animation-wise and start thinking state-wise

Thanks, but I’m still confused by the documentation.

I’m simply trying to trigger an animation with touch / or a mouseUp /
I’m not using curves or / another state to trigger

var animator : Animator;
function Start () {
    animator = GetComponent("Animator");

function Update () {
    if(Input.GetButtonDown("Fire1")) {
    animator.SetBool ("180Turn", Input.GetMouseButton (0));

    else {
       animator.SetBool ("Idle_Ready", Input.GetMouseButton (0));

Thanks in advance!