Footstep/Audio Events
Overview
To make footstep and audio event management as clean and generic as possible, AnimationClip Events are used.
This system still fully supports users independently creating and firing AnimationEvents for audio or whatever other reasons they have, so if you already have a mechanism for footstep or other animation event audio, this system can be ignored.
The workflow of the system centers around three AnimationEvent functions: NGFootstepEvent, NGRawAudioEvent, and NGAudioEvent.
These events are specified in animation clips, caught by the NGEventDispatchAnimationEvents script (on the same GameObject as the Animator and MxMAnimator components), where you can assign one or more of the following event handlers:
- OnRightFootstep(NGFootstepEvent): Fires on right footsteps that pass the "Min Time Between Same Foot Events" time threshold.
- OnLeftFootstep(NGFootstepEvent): Fires on left footsteps that pass the "Min Time Between Same Foot Events" time threshold.
- OnAnyFootstep(NGFootstepEvent): Fires on any footsteps without any "Min Time Between Same Foot Events" throttling.
These are triggered by setting Animation Events in each animation clip corresponding to the moment the relevant steps occur. See the picture below for an example Right Footstep event.
NGFootstepEvent
Event Field | Description |
---|---|
Function | NGFootstepEvent |
Int | FootIndex: 0 = Right, 1 = Left, but any number above 1 can be used for creatures with 3+ feet |
Float | (Optional, use only if you have a need to produce specific-duration footstep audio or e.g. VFX) duration (in seconds) of the footstep |
String | (Optional, default if blank: step) Type of footstep: step, scuff, slide, step_light, scuff_light, slide_light |
Object | Unused |
To receive these event notifications, register an event handler in the NGDispatchAnimationEvents component.
NGRawAudioEvent
This is a convenience event that will automatically play an AudioClip when the event fires without any further action/code required by the developer.
Event Field | Description |
---|---|
Function | NGRawAudioEvent |
Int | (Optional, default = 0 or Max (100%) Volume) Volume Level 1-10 => (10% -> 100%) |
Float | (Optional, use only if you have a need to produce specific-duration footstep audio or e.g. VFX) duration (in seconds) of the footstep |
Object | AudioClip to play |
String | Unused |