x


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

more ▼

asked Oct 01 '10 at 12:52 PM

Dave 7 gravatar image

Dave 7
11 1 1 2

I think you'll have better luck if you ask a more specific question. As you've found, there are plenty of examples of how to do this in the forums. If you're not having any luck with those examples, perhaps you could describe what you've tried and what sort of problems you've run into. (Also, I think this might be better suited as a forum thread rather than as a Unity Answers question.)

Oct 01 '10 at 02:49 PM Jesse Anders
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Oct 01 '10 at 04:14 PM

skovacs1 gravatar image

skovacs1
10k 11 25 92

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1200
x1060
x60

asked: Oct 01 '10 at 12:52 PM

Seen: 3899 times

Last Updated: Oct 01 '10 at 12:52 PM