Search Unity

Mix "run/walk" and "block" animation at same time

Discussion in 'Scripting' started by cruising, Jan 12, 2014.

  1. cruising

    cruising

    Joined:
    Nov 22, 2013
    Posts:
    329
    How do i do that?
    i use "adventurer" from assets store.

    here the script i have made
    Code (csharp):
    1. var swoosh : AudioClip;
    2.  
    3. function Start(){
    4. audio.clip = swoosh;
    5. }
    6.  
    7. function Update ()
    8. {
    9.    if (Input.GetMouseButton(0))
    10.  
    11.     {
    12.        animation.Play("swordStrike2");
    13.        audio.Play();
    14.        //yield WaitForSeconds ( 1.0 );
    15.  
    16.     }  
    17.        else if (Input.GetMouseButton(1))
    18.     {
    19.        animation.Play("swordStrike3");
    20.  
    21.     }  
    22.  
    23.    else
    24.     {
    25.       animation.CrossFade ("idle");
    26.     }
    27.    
    28.     if(Input.GetKey(KeyCode.LeftControl))
    29.     {
    30.     animation.Play("shieldBlock");
    31.     }
    32.    
    33.     else if(Input.GetKeyUp(KeyCode.LeftControl))
    34.     {
    35.     animation.Stop("shieldBlock");
    36.     }
    37. }
    38.