Game Development Community

How does Torque know which footstep sounds to play?

by Nicolai Dutka · in Torque Game Engine Advanced · 06/04/2009 (4:25 pm) · 14 replies

I see in my player.cs:

// Footstep Sounds
FootSoftSound = FootLightSoftSound;
FootHardSound = FootLightHardSound;
FootMetalSound = FootLightMetalSound;
FootSnowSound = FootLightSnowSound;
FootShallowSound = FootLightShallowSplashSound;
FootWadingSound = FootLightWadingSound;
FootUnderwaterSound = FootLightUnderwaterSound;

And the datablocks for each are pointing to the correct audio file. I finally got my sequence triggers to export and I am still not hearing the footsteps in game.... So... How does Torque know which of those footstep sounds to use?

#1
06/04/2009 (7:18 pm)
It's definitely not straightforward. Hopefully it's the same for TGEA as it is for TGE -- for the latter, you should find a file called "propertyMap.cs" in your /data/terrains folder as well as another in your /data/interiors folder. These basically dictate which sound to play based on the texture that the player is currently over (depending on if it's a terrain texture or an interior texture).
#2
06/04/2009 (7:41 pm)
Ok, that's getting me much closer. I found a propertyMap.cs in my TGEA 1.8.1 game examples. Now I just need to figure out what it all means:

addMaterialMapping( "stone" , "sound: 0" , "color: 0.46 0.36 0.26 0.4 0.0" );

I assume "stone" is the texture name, but "sound: 0" doesn't look familiar at all...
#3
06/04/2009 (7:45 pm)
Oh ya, and what about static shapes? I get no audio walking on them either...
#4
06/05/2009 (1:30 am)
Have a look here : it's the missing piece. ;-)

www.garagegames.com/community/forums/viewthread/2580

For static shapes, I don't know.

Nicolas Buquet
www.buquet-net.com/cv/
#5
06/05/2009 (7:44 am)
The number in the material mapping for sound "sound:0" is a hardcoded value that corresponds to certain sound types. I think there are four of them: soft, hard, snow, metal -- not sure about the order....

And I'm not sure if step sounds work on Statics (or ever have), I know that it used to be Terrains & Interiors only.
#6
06/05/2009 (7:50 am)
Oh, and since this is for TGEa, it has a bit of a diffferent setup than TGE (just checked out that link Nicolas left you)

First you have to set up some material templates:
new Material(TerrainSoft)
{
    FootstepSoundId = 0;       // Soft footstep sound defined on player datablock.
    ImpactSoundId = 0;         // Soft impact sound.
    ShowDust = false;          // Don't show dust particles (footpuffs, hover trails, etc.)
    ShowFootprints = true;     // But show footprints.
};

new Material(TerrainHard)
{
    FootstepSoundId = 1;       // Hard footstep sound defined on player datablock.
    ImpactSoundId = 1;         // Hard impact sound.
    ShowDust = true;           // Show dust particles.
    ShowFootprints = true;     // And show footprints.
};

Then you define a material for each of the blend textures.
new Material(TerrainDirtGrass : TerrainSoft)
{
    MapTo = "dirt_grass";
};

new Material(TerrainGrass1Dry : TerrainSoft)
{
    MapTo = "grass1-dry";
};

new Material(TerrainGrass1 : TerrainSoft)
{
    MapTo = "grass1";
};

new Material(TerrainGrass2 : TerrainSoft)
{
    MapTo = "grass2";
};

new Material(TerrainRocks : TerrainHard)
{
    MapTo = "rocks1";
   
    // Choose a grey-ish particle color for the dust emitters.
    EffectColor[0] = "0.5 0.5 0.5 1.0";
    EffectColor[1] = "1.0 1.0 1.0 0.0";
};
#7
06/05/2009 (8:52 am)
@Michael

So I stick all that into a script file, place the script file inside the folder containing the terrain textures, and execute it, correct?

Do I still need the:

addMaterialMapping( "stone" , "sound: 0" , "color: 0.46 0.36 0.26 0.4 0.0" );

Or is that just for TGE?
#8
06/05/2009 (11:49 am)
Ok, nvm... I found a 'materials.cs' file in one of my terrain texture folders... I must've missed it last time I checked. I also confirmed it is being executed by adding in an echo statement.

I verified my sequence triggers are being exported with the character by using Show Tool Pro. I can clearly see "Yes" in the trigger column when I view the sequences.

So I know that the materials are being assigned and the sequence triggers are exporting, but I am still not hearing any footstep sounds at all...

Lastly, what about stepping on static shapes?

I'm completely at a loss here... Anyone with Max 2009 and some knowledge in this mind looking at my character?
#9
06/05/2009 (12:25 pm)
Hmm, I'm not actually using a custom player (yet), but the above code was taken from the T3D example and I have it working for the Forge guy in the Stronghold example which is what my project was "templated" from.

Do you also have all of the needed datablocks for sounds setup and correctly named?

I would assume that the
"addMaterialMapping( "stone" , "sound: 0" , "color: 0.46 0.36 0.26 0.4 0.0" );"
bit would only work in TGE.

Sound on statics, are apparently a can't do it issue -- I didn't try very hard but couldn't get them working.

And I don't use Max so I'm afraid I couldn't offer any help there. You might be able to ask on the Artist sub-forums, a lot of helpful guys hang out there who don't really pay attention to the engine forums.

#10
06/05/2009 (12:30 pm)
Very insightful... honestly, I can't justify having footstep sounds on terrain but not on statics in the game I am working on simply because it is based very heavily on 'platforming' and has a bunch of levels that are entirely interior... It wouldn't really fit to have footstep sounds only 30% of the time... :P

Thanks a TON for the help!!
#11
06/07/2009 (11:01 am)
For clarification:

TGE's material property maps (MPMs) no longer are a part of TGEA (or Torque 3D for that matter). 'addMaterialMapping' has a completely different meaning in TGEA and the old propertyMap.cs files just haven't been purged in 1.8.1 as they should have been. addMaterialMapping sets up material to texture mappings like mapTo.

The system that replaces MPMs is material-based behavioral properties as Michael has described them above. This system is much cleaner as it directly ties into the collision system and does not require the code that's scanning for collisions to know the type of objects being hit.

The only quirk is that certain object types (currently terrains) may use their own material system. In that case, faux-materials with just the behavioral properties must be set up and mapped to the textures used by the given object.
#12
06/07/2009 (11:11 am)
Nicolai,
i can't understand why do you suffer with this simple functionality.
You can set the triggers in 3d studio,then in c++ get the trigger states and play the sound.
#13
06/07/2009 (7:47 pm)
Picasso,

Exactly my point... It is SUPPOSED to be easy, it looks really easy, the guide I followed was easy, but the damn thing just won't work... I graduated from college with a Bachelor's Degree of Science in Game Design and Development where I was educated largely in TGE. You would think I would have no problems implementing this feature... That's why I have been posting about it... It SHOULD be easy for me and yet it simply refuses to work...
#14
06/08/2009 (12:27 am)
Use getTriggerState(N) , where N is the trigger counter.
And use SFX->playOnce() to play the sound.