Footstep audio for FPS

Hi, I am currently trying to get a footsteps track to play while I move through a scene (FPS). I have seen a lot of scripts on the forums but I dont know how or where to place these - any help would be greatly appreciated as I have never done any kind of scripting, really need a step by step! Thanks Dave

This question is really quite general, but I'll try to be as specific as I can.

Going through the tutorials and checking out their setups is a great way to start. I recommend checking out the 2D platformer tutorial specifically as I know that it has sound on footfalls.

Their setup has the following:

  1. A script on each surface specifying a collision sound effect.
  2. A script on Foot Effects transforms in the hierarchy which have rigidbodies and colliders
  3. In the script on the Foot Effects, it checks for collision, looks for the sound effect on what it collided with and then plays it.

It is possible that your FPS doesn't actually have a player character but a camera floating in space. In this case, you would have to decide how and when to trigger your sounds.

To play audio, you can do something like:

audio.clip = collisionSoundEffect.audioClip;
audio.Play();

or

audio.PlayOneShot(collisionSoundEffect.audioClip);

You would do this whenever you move. You could do some boolean checking (as a lock) to prevent playing the sound too frequently, possibly with a coroutine to wait a specified amount of time or something to control the flag.