Game Development Community

Random footsteps

by Thomas Shaw · in General Discussion · 06/07/2005 (7:29 pm) · 8 replies

So I want to randomize my footstep sounds a little bit. Right now I have a LOT of single footsteps that I made in a sound studio on different types of terrain.

I want the game to just pull a random one of seven (for each terrain type) to add a little bit of variety to the audio experience. Any thoughts?

#1
06/07/2005 (7:38 pm)
Shouldn't be too hard if you know C++

in the engine\game\player.cc
Player::playFootstepSound around line 3975 has a switch block for soft, hard, metal, etc. You could add some random routines inside of the appropriate case block.

B--
#2
06/07/2005 (8:07 pm)
I'm really rusty on C++, could I maybe get an example?
#3
06/07/2005 (9:19 pm)
This is a public forum, so code examples could not be posted here, but it would only take very basic understanding to get the ramdom sounds working. The solution would be as follows:

1. Add some additional sounds to the player datablock in script.

2.Add the sound types to the enum block around line 100 in player.h

3.In the player.cc C++ file around line 3975 inside one of the case blocks add some basic random logic:

Currently the case block calls an alxPlay routine with a reference to the enum definition that mirrors the script sound datablocks.

Just use the current alxPlay routine call as a template to add additional sounds with a random aspect. Use the MRandomGenerator class to give you a number between for example 0 thru 4. Then use this random number to play one of your additional sound files that you have defined.

If your C++ skills aren't up to a switch/case or if/else segment of code, then I don't think you would find it very easy to implement this feature.

If you can't get it to work after some attempts, I could throw together an example for you in the private forums in a few days.

B--
#4
06/08/2005 (12:10 am)
Ok, I finished my stuff early, and posted a quick answer for ya here:

Code Example

B--
#5
06/08/2005 (9:50 am)
Some info .
Torque has footstepsounds based on materials , atleast on the terrain .
Havent seen any materialmap fix for interiors yet.
#6
06/08/2005 (10:23 am)
Yeah, I didn't mean to post in the public forums, since I AM an SDK owner.

Thanks Brandon. If you test this you should upload it as a resourse ^^
#7
06/08/2005 (12:23 pm)
Yeah, I didn't mean to post in the public forums, since I AM an SDK owner.

Thanks Brandon. If you test this you should upload it as a resourse ^^
#8
06/08/2005 (3:35 pm)
Yeah, I didn't mean to post in the public forums, since I AM an SDK owner.

Thanks Brandon. If you test this you should upload it as a resourse ^^