Search Unity

Playing animations with Unity Animator

Discussion in 'Animation' started by TheDiddyHop, Feb 28, 2015.

  1. TheDiddyHop

    TheDiddyHop

    Joined:
    Jul 26, 2013
    Posts:
    30
    Hi, i'm working on the animations for guns in my fps game however i cannot figure out how to get animations working.

    The way my script works is when the weapon is fired it tells another script (Animation manager) that the gun is firing. The animation manager script then plays the animation. Fairly simplistic but i simply can't get the animations to work.

    I would like this code to be able to be applied to multiple weapons.

    Here's what my first attempt was (though i did go through many variations)

    Code (JavaScript):
    1. var Firing : boolean = false ;
    2.  
    3. //animations
    4. var FireAnim : AnimationClip ;
    5.  
    6. function Update ()
    7. {
    8.     if (Firing == true)
    9.     {
    10.     animation.Play("Fire"); //This line has been changed several times, this is my most basic attempt
    11.     Firing = false ;
    12.     }
    13. }
    14.  
    I'm still in the process of learning code so it may be a dumb mistake.
     
  2. TheDiddyHop

    TheDiddyHop

    Joined:
    Jul 26, 2013
    Posts:
    30
    Seriously need a response.
     
  3. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675