- Home /
 
Animation Event Bug
Ok so I have an object and it has an animator component attached and a script... now inside that script, I have a function called "shoot". The problem is when I tried to add an animation event, the function shoot won't show up!(well no function shows up on the dropdown menu) Is this a unity bug or what? I tried creating a new project and do the same thing, but this time I can see my created functions...
               Comment
              
 
               
              it's a simple code to play a sound: void shoot(){ shootSound.Play();}
shootSound is a variable for it's audio source component
 
               Best Answer 
              
 
              Answer by FairGamesProductions · Nov 08, 2014 at 11:12 AM
Why not just do something simple like this (js):
 private var GunAnimator : Animator;
 var FireRate = 1.0;
 
 function Start ()
     {
     GunAnimator = gameObject.GetComponent(Animator);
     }
 
 function Update ()
     {
     if (Input.GetMouseButtonDown(0) && counter > FireRate)
         {
         counter = 0.0;
         GunAnimator.SetTrigger("Shoot");
         gameObject.audio.Play();
         //And instantiate your bullet here too...
         }
     counter += Time.deltaTime;
     }
 
              Your answer