FOOTSTEP Implementation FUNCTION
This is a function that handles many details and requirements for footsteps. It could be called from a ‘bread crumb’ subsystem, notifies attached to animations (not advised!) or from an alternative system. By passing multiple parameters and data from the central player character, and abstracitng audio logic away, different disciplines can work from the same data while also avoiding inefficiently doing double work to figure out materials, water depth, etc.
It handles:
Perspective (1p or 3p)
Player stance (standing, crouched, prone)
Material
Water
Is dying
Water and water depth
Weight*
// Player character references
Get a reference to the player character
Provides AK component that isn’t created or destroyed for each footstep
Provides phsyical material (by getting physical material with a single line trace on the player character, multiple disciplines can use the same line trace, work from the same information, and avoid repeatedly working out the same results by all individually running an expensive line trace)
Set the occlusion threshold for these sounds (we later bypass occlusion if we’re handling 1P footstep sounds)
//Adding Weight handling
Although this project didn’t require weight handling, it could easily be handled
Add weight component to player character
Normalise weight value as a float between 0 and 1 by mapping the range of min character weight and max character weight
Pass normalised weight value from player character to footstep function
Drive RTPC that is passed to Wwise that affects volume mixes (gear, foot, clothes, etc) and blend container for light, medium and heavy footsteps
//water, materials and state
Handle water
Deep or shallow
WaterManagementSubsystem attached to the player character provides the data
Audio is abstracted away and evaluates the date that it is passed from the player character
If shallow water, play shallow water footsteps
If deep water (as defined by flaot threshold) player deep water
If not in water, read the physical material from the player character, and set the switch group
Handle sprint/walk
Set an RTPC to drive blend container and change the mix of material/gear/weapon/clothing
//Stance, perspective, death
Handle stance
Select the right sound for standing, prone or crouch movement
Check if the player has died
Defined by the player character
If the player has tied when this function is called, don’t actually end up playing a sound
Define the perspective of the sound, based on locally controlled bool
If 1p, bypass occlusion.