1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. We want to know how you learned Unity! Help us by taking this quick survey and have a chance at a $25 gift card
    Dismiss Notice
  5. Are you an artist or level designer going to Unite Europe? Join our roundtables there to discuss artist features.
    Dismiss Notice
  6. Unity 5.6 is now released.
    Dismiss Notice
  7. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice

2 Animations at once

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

  1. Duskling

    Duskling

    Joined:
    Mar 15, 2011
    Posts:
    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