Final Major Project - Footsteps
Updated: Apr 29, 2021
Who would've thought that a simple feature like footstep audio would become such a huge problem-solving challenge? Certainly not me. While in first person games you can simply have the audio play on a time interval, it is not so easy in top down, third person or any other views that let you see a characters feet. A similar method to the time interval for third-person games I came across was to use animation events , however as I am using blend trees to get movement at different speeds and directions this becomes unreliable.
My fundamental logic for all my approaches was to have trigger colliders on the player characters feet and play a sound when OnTriggerEnter is called. My first iteration is a very simple application of this idea with a trigger collider beneath each of the players feet.
This iteration has several issues however, the triggering of the sounds would not reliably play at the correct time and sometimes would not trigger at all on sloped ground. It also did not cope well when walking backward, with sounds trigger multiple times per step.
My next attempt to try and fix these issues was to not detect collisions with the ground at all but with a bar that was through both feet, then as the sphere colliders on the feet go back and forth through this bar the audio is triggered. By relying on a bar at a constant position rather than the ground I would be able to trigger a sound more reliably and completely negate any issue cause by non-flat terrain.
While this did work well for standard movement it was not as successful for combat movement as the hips of the player character turn diagonal which renders the bar next to useless as it is no longer in the right place for where the feet now are.
To combat this I made it, instead of a bar, have a whole box underneath the feet of the player, essentially having a fake floor just to detect footsteps. This meant that because the fake floor was at a guaranteed height, I could have the sphere colliders in the feet only poke out the smallest amount enabling very accurate step detections and as with the bar because it works independent of the terrain slopes and other similar issues become no problem at all.
It was very interesting to tackle this problem, especially because I did not expect it to come from something so mundane as footsteps, but it really let me dig my teeth into some problem solving and iteration. It also doesn't hurt that the end result is very high quality and pleasing as simple footstep noises can do so much for atmosphere.