You want to know where my player is? Nah, I ain’t going to snitch my hiding place!

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.

Having an event happen in the middle of my boss animation where it Instantiates a scatter shot.

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.

The script to instantiate a bullet that scatters in a 360 degrees.

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.

Only when selecting the event icon in the dopesheet would this feature show in the Inspector.

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.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Simon Truong

Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.