1. The 5.5 Beta is now available. Click here for more details!
  2. Get early access to our Google Daydream Technical preview. Click here for more details!
  3. Become a closed-alpha partner on the new Facebook games platform. Read more about it here.
  4. Enter the Samsung TIZEN App Challenge for a chance to win prizes. Read more about it here.

2 Animations at once

Discussion in 'Scripting' started by Duskling, Feb 1, 2012.

  1. Duskling

    Duskling

    Joined:
    Mar 15, 2011
    Messages:
    1,197
    I read about animation mixing, but that didn't work for me.

    Code (csharp):
    1.  
    2. function Animations()
    3. {
    4.     if(weaponsController.gunScript)
    5.     {
    6.         animation.AddClip(weaponsController.gunScript.weaponIdleAnim, "weaponIdleAnim");
    7.         animation.Blend("weaponIdleAnim");
    8.     }
    9.    
    10.     // Running
    11.     if(Input.GetAxis("Vertical") > .1  controller.isGrounded)
    12.     {
    13.         animation.CrossFade("run", 0.3);
    14.     }
    15.    
    16.     else if(Input.GetAxis("Vertical") < -.1  controller.isGrounded)
    17.     {
    18.         animation.CrossFade("back", 0.3);
    19.     }
    20.    
    21.     else
    22.     {
    23.         if(Input.GetAxis("Horizontal")  !Input.GetAxis("Vertical")  controller.isGrounded)
    24.         {
    25.             animation.CrossFade("turn",0.3);
    26.         }
    27.         else if (controller.isGrounded)
    28.         {
    29.             animation.CrossFade("idle", 0.1);
    30.         }  
    31.         else
    32.         {
    33.             animation.CrossFade("jump", 0.3);
    34.         }  
    35.     }
    36. }
    37.  
    Everything is working fine, but I just want "weaponIdleAnimation" to play correctly while you are running, jumping etc. weaponIdleAnimation is being added, but trying to animate it either overrides all the other animations or doesn't play at all.
     
    Last edited: Feb 1, 2012