Animation Event Trigger

As you are looking through the inspector fields on the Ultimate Character Controller objects you’ll see a field which looks similar to this field within the Jump ability:

This field is an Animation Event Trigger and it allows you to specify if the object should wait for an animation event before the event is triggered or if a timer should be used instead with a specified duration. In this screenshot Wait For Animation Event is enabled which means the Jump ability will wait for the “OnAnimatorJump” event. For the animation event ensure theĀ Function name is “ExecuteEvent” and the String value is the animation event that you want to call.

The animation event that it is looking for can be determined by either hovering over the Jump Event field and reading the tooltip or look at the Tooltip attribute for that field within the code.

If you are using animation events with an item (such as using the item or reloading it) and are using both a first and third person perspective be sure change the animation event for both perspectives.

Animation Event Debugging

If Wait For Animation Event is enabled the animator will send the event. Debugging when this event is sent can be done by enabling Log Events on the Animator Monitor component. In the OnAnimatorJump example the following will be outputted to the console when Log Events is enabled:

The Animator.Update line is highlighted because it is here that we can see that the Animator is responsible for sending the animation event. If Wait For Animation Event was not selected then the event would be sent from the Scheduler and the call stack would be different.

If you are having issues with the timing of when events occur a good debug step is to look at this call stack to determine when the event is being triggered. If it is being triggered too soon and it is being triggered from the Animator then you should move the animation event later in the animation. If you are working in a first person perspective and have a full body animation ensure that this event is changed on both the first person and third person Animator.