Footsteps Sounds in Unity3D C# code example

This was my old attempt to implement footsteps sounds in Unity 3D which I did use to test my sounds (it was used, inter alia, here /footsteps-in-unity3d/) some time ago. If you need some easy example, then it may help you. Or else. It is written in C# in Unity3D 4.x but it is still works with Unity 5.x. It uses Resources.Load which maybe isn’t the most efficient way of loading sounds to the memory but it is an easy one. It works with default First Person Controller. The script supports switching footsteps type based on splatmap detection and object collision.

To contains two scripts footstepsSound.cs and footstepsSoundClass.cs.  In order to work you need to creat it into your project and attach footstepsSound.cs script to First Person Controller. Continue reading “Footsteps Sounds in Unity3D C# code example”

Footsteps pack 1

Online demo of Footsteps Pack 1 for Unity Asset Store

Contols: WASD keys + Mouse to move and look around. Shift to run, space to jump.

Mozilla Firefox browser is required. To open fullscreen use the icon at the bottom.

[unity src=”749″]

Footsteps in Unity3D

This is footsteps sounds testing area where you can walk on various surfaces and hear different versions of sound.

The footstep sound set is determined by collision with terrain and objects. The footsteps script examines whether the Player is walking on the Terrain or the other object. If  Terrain is detected under the Player’s foot version of the footsteps is determined by examining Terrain Texture.

Because Terrain Textures can me mixed and scattered there is kind of ‘sound antialiasing’ applied (not in the literal sense). This is done by mixing recently played footstep sound type with the new one. Volume of the old one is decreased to some degree (~50%). This alleviate a little an unpleasant effect of quick switching between sets of footsteps – especially when single footstep of the whole set is played and then switched to another. This helps the Player to percieve background sound as nicely blended and less discrete (binary 0/1). You can test the difference of ‘footsteps antialiasing‘ by switching it off or on using ‘E’ key. By default it is turned on.

Footsteps are shuffled and tempo of steps is based on Players speed.

There are two areas where you can hear a reverb on footsteps. One is achieved with Unity3ds Reverb Zone. The second one uses stereo samples with mixed prerendered Reverb. The second  solution takes much more memory than the first one because of stereo sound and long reverb tails.

Controls: WASD + Mouse and left shift to run. It doesn’t work in Chromium based browsers anymore (Chrome, Opera) so you have to use Firefox or else.

Update info (06.2017): due to policy changes and lack of updates of old webplayer by Unity, online example seems not to work in any of current browsers. Sorry.

[unity src=”749″]