Footsteps have been introduced in Solani a while back, but they were using magic numbers and inefficient code.
Adding Sounds was simply impossible since the footsteps didn’t match with the actual foot positions of the Player. This was not so visible, thus not so important when only the footprints were there, but when adding the sounds, it become too obvious that something was wrong.
To fix this, I had to figure out a way to find out if the foot of the Player, that was attached to one of the Bones, was touching the ground. Since his feet are animated, they don’t always touch the ground perfectly. Calculating the difference between the hips bone and the foot bone actually gave us a result that looks right in almost every case.
Also the rotation had to be taken care of. The print has to be aligned with his foot, but also be parallel with the ground. Using some raycasts and cross product maths did the trick.
Since instantiating and destroying the footstep objects every time is a very heavy operation, I added pooling to optimize this simple script. Hiding and unhiding these GameObjects is way better performance-wise.