1. Unity 5.6 is now released.
    Dismiss Notice
  2. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  3. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice
  4. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  5. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  6. Check out all the fixes for 5.5 in patch releases 1 & 2.
    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