Game Development Community

Using Different Footstep Sounds

by Yin Yi Jia · in Torque Game Engine · 12/14/2005 (9:02 am) · 8 replies

I posted this earlier in the General Technical Issues/Audio forum and member Owen Ortmayer suggested I post in the Private SDK forum to get his solution...

>Can anyone tell me what the simplest way of implementing different footstep sounds would be for inside/outside. I see there are many different footstep profiles for snow, water etc. Basically I would just like to have one sharp echoey sound for inside (DIF structures) and another flatter grassy sound for outside (on the terrain).

Is there an easy way to implement this?

Any advice would be most appreciated

#1
12/14/2005 (9:06 am)
Hey Yin, I had to add a little source hack to get this working. In game/player.cc in the the Player::updateActionThread(), (about line 2141) I added an additional if statement to set the sound played when over an interior:

else if ( rInfo.object->getTypeMask() & VehicleObjectType)
   sound = 2; // Play metal sound

//Select the metal sound if we are over an Interior
[b]else if ( rInfo.object->getTypeMask() & InteriorObjectType )
    sound = PlayerData::FootMetal;[/b]
#2
12/14/2005 (11:00 am)
Hi Owen

Many thanks for the code I will give it a try. So I presume one just adds the desired wav file to the FootLightMetalSound audio profile in the [player.cs] file ?
#3
12/14/2005 (3:04 pm)
Hmm it looks like i have to add some code.
I thought this was fixed a long time ago.

add and replace in Player.cc
around line 2098 change


S32 mapIndex = tBlock->mMPMIndex[0];
to
S32 mapIndex = tBlock->getTerrainMapIndex(rInfo.point);


add after

   if ( rInfo.object->getTypeMask() & VehicleObjectType)
       sound = 2; // Play metal sound

 else
         if( rInfo.object->getTypeMask() & InteriorObjectType)
            {
MaterialPropertyMap* pMatMap = static_cast<MaterialPropertyMap*>   (Sim::findObject ("MaterialPropertyMap"));   
const MaterialPropertyMap::MapEntry* pEntry = pMatMap->getMapEntryFromIndex(rInfo.material);
		   if(pEntry)
		   sound = pEntry->sound;
			   
	   }  
	    
	    else
	       sound = 0;

in InteriorCollision.cc add
#include "dgl/materialPropertyMap.h"
#include "dgl/materialList.h"

around line 452

after
info->face = surfaceIndex;

MaterialPropertyMap* pMatMap = static_cast<MaterialPropertyMap*>(Sim::findObject("MaterialPropertyMap"));
const char* pName = mMaterialList->getMaterialName(rSurface.textureIndex);
 	info->material = pMatMap->getIndexFromName(pName);
	
	if (info->material == -1)
	{
	    info->material = 0; //Default sound if no sound specified
	}

And for the scripts

terrain materialmapping propertyMap.cs

addMaterialMapping( "sand" , "sound: 0" , "color: 0.96 0.36 0.26 0.4 0.0" ); 
addMaterialMapping( "grass" , "sound: 1" , "color: 0.46 0.96 0.26 0.4 0.0" ); 
addMaterialMapping( "patchy" , "sound: 2" , "color: 0.46 0.36 0.96 0.4 0.0" ); 

interior materialmapping propertyMap.cs

copy the starter.fps/data/terrain/grassland/propertyMap.cs to starter.fps/data/interiors

change it to this

addMaterialMapping( "Floor_slate01" , "sound: 0" ); 
addMaterialMapping( "Floor_tile01" ,  "sound: 1" ); 
addMaterialMapping( "FlrFiller3_01" , "sound: 2" );
addMaterialMapping( "FlrFiller3_02" , "sound: 3" ); 
addMaterialMapping( "FlrFiller3_03" , "sound: 1" );

This is based on many different guys buggfixes and codes in the forum .
I changed this in Torque 1.4 and footstep sound work both on interiors and terrain + the footpuff colors depending on the material.
Hope i got it all here.
#4
12/15/2005 (7:46 am)
Hello

Just to let you know, I tried Owen's code above in player.cc, compiled and it works great! The only other change which was necessary is to go into player.cs, in your "server" folder, and look at your footstep audio profiles, mine looks like this:

// This footstep profile is activated for when player is outside on terrain
datablock AudioProfile(FootLightHardSound) {
   filename    = "~/data/sound/misc/footfall.wav";
   description = AudioClose3d;
   preload = true;
};

// This footstep profile is activated for when player is inside interiors
datablock AudioProfile(FootLightMetalSound) {
   filename    = "~/data/sound/misc/footfall02_reverb.wav";
   description = AudioClose3d;
   preload = true;
};
#5
12/15/2005 (9:55 am)
Ye with Owens fix you get 1 sound ,but if you want fully working sounds on every material or other colors on the footpuffs then you should try the one i submitted.
#6
05/01/2006 (8:52 am)
How about foot step sounds for side strafe and back movement? I dont seem to hear any.
#7
05/01/2006 (3:48 pm)
@Howard
Did you add the footstep triggers to your strafe and back animation ?
Othervise it's not working !
#8
06/27/2006 (10:02 am)
@Billy
Thanks so much. That works like a charm.