Let us go through the nodes within the patch from left to right and see how this system work:
- Listener Scene Location – This node will keep track of the position of the listener that is placed on the camera found on the player within the game.
- Distance to Pulse – This is a special node that will keep track of something in the scene, the listener in this example, and once it has moved a specified distance (set by the threshold) a pulse will be sent out.
- Pulse Switch: Materials – You can create a Pulse switch node from any Enum Asset you have available, and in this example, we have created an Enum with the two items “Concreate” and “Metal”. In this case, the switcher can then be in either of these two states.
- Connected to the switcher is the global Enum parameter, and this is the parameter that the game sets as the player steps on each surface type.
- Randomizer – Branching off after the Distance to pulse we also have a randomizer node, that when getting a pulse, will randomize a value between the specified minimum and maximum values. This one connects to the pitch socket on the two sound players to add some more variation to every step.
- The two sound players – The two sound players represent the two different surface types, so they each contain 7 samples of the footsteps. Which one of the two sound players that is going to be played is depending on the state of the global “FootstepMaterials” parameter.
- The sound players output the sound to the same Output node and will play the sound through the selected group channel called “Master”, found in the mixer.
To summarize: the movement of the listener will generate pulses in even intervals that will first look at what current material type is active and then play the corresponding sound player.