Framework 2: Animation Events
Calling public methods in the Animation Dopesheet
Now that we have a fully functional Boss Ai created by using the Unity Animator. We can add special “Timed” events within the Animation window to trigger some special effects.
For example, being able to fire bullets when your boss character moves to a certain location or if your boss character preforms a certain animation movement.
Adding the Event
To add an event simply select the desired location within the timeline (ie. 2 seconds in the animation) and click the top left button within the animation window. A new icon would appear on the top of the dopesheet at exactly were you left the scrubber.
Adding Function to the event
Back in the boss behavior script, we need to create a new public method which can be called by the animation event. In my example, I want the boss to fire an scatter shot of bullets.
Once that is done, back in the Inspector, select the created event and the Inspector should show you a drop down menu with an list of available public methods. Select the function you need and you should be set.
This feature is great because you can have perfectly timed events to be called every single time the scrubber passes this event mark, which can lead to create some very unique game play.