1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  3. All Unity Pro perpetual license customers: your special offer to subscribe is ready! Click here.
    Dismiss Notice
  4. Unity 5.5 is now released.
    Dismiss Notice
  5. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  6. Unity 5.6 beta is now available for download.
    Dismiss Notice
  7. Get prepared for the Tizen Mobile App Incentive Program! Read more about the upcoming program here.
    Dismiss Notice
  8. Enter the Microsoft Developer Challenge for a chance to win prizes. Read more about it here.
    Dismiss Notice

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