Footstep sounds
by Kaya Dogan · in Torque Game Engine Advanced · 04/18/2007 (5:47 am) · 14 replies
We need different footstep sounds for our project. I wrote the required code, but all I got was the "default" sound when walking around. Now I noticed, that some code has been commented out in player.cpp. But when re-enabling that stuff, the game crashes every time I try to walk.
The code is in player.cpp (Player::updateActionThread()):
S32 mapIndex = tBlock->mMPMIndex[0];
if (mapIndex != -1) {
MaterialPropertyMap* pMatMap = MaterialPropertyMap::get();
const MaterialPropertyMap::MapEntry* pEntry = pMatMap->getMapEntryFromIndex(mapIndex);
if(pEntry)
{
sound = pEntry->sound;
I noticed, that the line "sound = pEntry->sound;" crashes - now what can I do?
The code is in player.cpp (Player::updateActionThread()):
S32 mapIndex = tBlock->mMPMIndex[0];
if (mapIndex != -1) {
MaterialPropertyMap* pMatMap = MaterialPropertyMap::get();
const MaterialPropertyMap::MapEntry* pEntry = pMatMap->getMapEntryFromIndex(mapIndex);
if(pEntry)
{
sound = pEntry->sound;
I noticed, that the line "sound = pEntry->sound;" crashes - now what can I do?
#2
04/18/2007 (8:39 am)
Hmmm...I tried pEntry->sound and (for testing) pEntry->name...both caused a crash. I am sure, that the brackets are set correctly. The script-side stuff is done. It does play the files I set as default in the C++ code. But it just seems to ignore the propertyMap.cs entries for sound...
#3
04/18/2007 (10:54 am)
.
#4
Alright - here's my TorqueScript code for that (note, that I added a lot of fields from the C++ side).
File is server/scripts/player.cs
First the datablocks:
Now the assignments:
04/18/2007 (12:20 pm)
I removed the if-stuff...but it won't stop crashing at the same code-line...Alright - here's my TorqueScript code for that (note, that I added a lot of fields from the C++ side).
File is server/scripts/player.cs
First the datablocks:
//----------------------------------------------------------------------------
datablock AudioProfile(walk_grass1)
{
filename = "~/data/sound/Movement/Footsteps/fs_grass1.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_grass2)
{
filename = "~/data/sound/Movement/Footsteps/fs_grass2.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_grass3)
{
filename = "~/data/sound/Movement/Footsteps/fs_grass3.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_grass4)
{
filename = "~/data/sound/Movement/Footsteps/fs_grass4.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_grass5)
{
filename = "~/data/sound/Movement/Footsteps/fs_grass5.wav";
description = AudioClosest3d;
preload = true;
};
//----------------------------------------------------------------------------
datablock AudioProfile(walk_dirt1)
{
filename = "~/data/sound/Movement/Footsteps/fs_dirt1.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_dirt2)
{
filename = "~/data/sound/Movement/Footsteps/fs_dirt2.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_dirt3)
{
filename = "~/data/sound/Movement/Footsteps/fs_dirt3.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_dirt4)
{
filename = "~/data/sound/Movement/Footsteps/fs_dirt4.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_dirt5)
{
filename = "~/data/sound/Movement/Footsteps/fs_dirt5.wav";
description = AudioClosest3d;
preload = true;
};
//----------------------------------------------------------------------------
datablock AudioProfile(walk_sand1)
{
filename = "~/data/sound/Movement/Footsteps/fs_sand1.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_sand2)
{
filename = "~/data/sound/Movement/Footsteps/fs_sand2.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_sand3)
{
filename = "~/data/sound/Movement/Footsteps/fs_sand3.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_sand4)
{
filename = "~/data/sound/Movement/Footsteps/fs_sand4.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_sand5)
{
filename = "~/data/sound/Movement/Footsteps/fs_sand5.wav";
description = AudioClosest3d;
preload = true;
};
//----------------------------------------------------------------------------
datablock AudioProfile(walk_snow1)
{
filename = "~/data/sound/Movement/Footsteps/fs_snow1.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_snow2)
{
filename = "~/data/sound/Movement/Footsteps/fs_snow2.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_snow3)
{
filename = "~/data/sound/Movement/Footsteps/fs_snow3.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_snow4)
{
filename = "~/data/sound/Movement/Footsteps/fs_snow4.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_snow5)
{
filename = "~/data/sound/Movement/Footsteps/fs_snow5.wav";
description = AudioClosest3d;
preload = true;
};
//----------------------------------------------------------------------------
datablock AudioProfile(walk_wood1)
{
filename = "~/data/sound/Movement/Footsteps/fs_wood1.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_wood2)
{
filename = "~/data/sound/Movement/Footsteps/fs_wood2.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_wood3)
{
filename = "~/data/sound/Movement/Footsteps/fs_wood3.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_wood4)
{
filename = "~/data/sound/Movement/Footsteps/fs_wood4.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_wood5)
{
filename = "~/data/sound/Movement/Footsteps/fs_wood5.wav";
description = AudioClosest3d;
preload = true;
};
//----------------------------------------------------------------------------
datablock AudioProfile(walk_stone1)
{
filename = "~/data/sound/Movement/Footsteps/fs_stone1.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_stone2)
{
filename = "~/data/sound/Movement/Footsteps/fs_stone2.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_stone3)
{
filename = "~/data/sound/Movement/Footsteps/fs_stone3.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_stone4)
{
filename = "~/data/sound/Movement/Footsteps/fs_stone4.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(walk_stone5)
{
filename = "~/data/sound/Movement/Footsteps/fs_stone5.wav";
description = AudioClosest3d;
preload = true;
};
//----------------------------------------------------------------------------Now the assignments:
// Footstep Sounds FootGrassSound = walk_grass1; FootDirtSound = walk_dirt1; FootSandSound = walk_sand1; FootSnowSound = walk_snow1; FootWoodSound = walk_wood1; FootStoneSound = walk_stone1; fs_grass1_sound = walk_grass1; fs_grass2_sound = walk_grass2; fs_grass3_sound = walk_grass3; fs_grass4_sound = walk_grass4; fs_grass5_sound = walk_grass5; fs_dirt1_sound = walk_dirt1; fs_dirt2_sound = walk_dirt2; fs_dirt3_sound = walk_dirt3; fs_dirt4_sound = walk_dirt4; fs_dirt5_sound = walk_dirt5; fs_sand1_sound = walk_sand1; fs_sand1_sound = walk_sand2; fs_sand1_sound = walk_sand3; fs_sand1_sound = walk_sand4; fs_sand1_sound = walk_sand5; fs_snow1_sound = walk_snow1; fs_snow2_sound = walk_snow2; fs_snow3_sound = walk_snow3; fs_snow4_sound = walk_snow4; fs_snow5_sound = walk_snow5; fs_wood1_sound = walk_wood1; fs_wood2_sound = walk_wood2; fs_wood3_sound = walk_wood3; fs_wood4_sound = walk_wood4; fs_wood5_sound = walk_wood5; fs_stone1_sound = walk_stone1; fs_stone2_sound = walk_stone2; fs_stone3_sound = walk_stone3; fs_stone4_sound = walk_stone4; fs_stone5_sound = walk_stone5;
#5
04/18/2007 (3:02 pm)
.
#6
When commenting it out, the 'default' sounds are played (those I defined in the 'default' case), which is the dirt sounds.
04/18/2007 (4:06 pm)
I'm using legacy terrain. The game won't crash, when I comment "sound = pEntry->sound" out. None of the 'pEntry'-members work without crashing the game...When commenting it out, the 'default' sounds are played (those I defined in the 'default' case), which is the dirt sounds.
#7
04/19/2007 (12:44 am)
.
#8
04/23/2007 (4:33 pm)
I implemented footstep sounds in our project, but we're using Atlas instead of Legacy, so theres no per-pixel differentiation on terrain for Dirt versus Snow, etc (unfortunately)
#9
The second script block - what's that coming from? I don't recall ever seeing a script block like that in stock Torque. Are you using a resource here? (It's also possible I just never messed with that part of Torque before. :)
04/24/2007 (3:28 pm)
PEntry is likely pointing to corrupt memory. Check it in the debugger and you'll likely see it's pointing to 0xcececece or something similarly bogus.The second script block - what's that coming from? I don't recall ever seeing a script block like that in stock Torque. Are you using a resource here? (It's also possible I just never messed with that part of Torque before. :)
#10
The second block is the result of some additional C++ coding work - I added some fields and added them to the footstep-sound switch() block.
04/24/2007 (3:42 pm)
Any workaround for that issue?The second block is the result of some additional C++ coding work - I added some fields and added them to the footstep-sound switch() block.
#11
Crash might be related to the additional fields you added; you might want to confirm they're being set properly and getting registered in the right places as well as being networked to the client object properly too.
04/24/2007 (3:57 pm)
For the issue of getting a bad pointer? Sure - step through the code in a debugger and identify the logic that's causing a bad pointer to be returned. :) It doesn't crash in stock Torque, so there's nothing I can do on my end to help you besides point you in the right general direction and help you interpret your findings.Crash might be related to the additional fields you added; you might want to confirm they're being set properly and getting registered in the right places as well as being networked to the client object properly too.
#12
Everything else looks good.
Unfortunately there are no hints where the errors might come from. Seems like this is going to be a looooong day for me today ;)
04/25/2007 (1:59 am)
Thanks Ben. The Debugger tells me the following:pEntry 0x36532738 {name=??? detailMapName=??? environMapName=??? ...} const MaterialPropertyMap::MapEntry *
name CXX0030: Error: expression cannot be evaluated
detailMapName CXX0030: Error: expression cannot be evaluated
environMapName CXX0030: Error: expression cannot be evaluated
bumpMapName CXX0030: Error: expression cannot be evaluated
materialName CXX0030: Error: expression cannot be evaluated
matType CXX0030: Error: expression cannot be evaluated
matFlags CXX0030: Error: expression cannot be evaluated
environMapFactor CXX0030: Error: expression cannot be evaluated
sound CXX0030: Error: expression cannot be evaluatedEverything else looks good.
Unfortunately there are no hints where the errors might come from. Seems like this is going to be a looooong day for me today ;)
#13
My guess is that you'll run into another of those wonderful massive blocks of commented out code.
04/25/2007 (4:53 am)
You need to step into these methods you're using.MaterialPropertyMap::get(); getMapEntryFromIndex
My guess is that you'll run into another of those wonderful massive blocks of commented out code.
#14
We need a good workaround for that...what we need is at least the material name of the terrain piece the player currently walks on. That would be a good starting point to get this thing fixed...hopefully...
@Jacobin: commented out? yeah...and...completely removed *lol* Looks like GG have just disabled this feature for now...
05/09/2007 (2:53 pm)
After looking deeply into the methods used, we noticed that the mMPMIndex array of the TerrainBlock class is not initialized at all. We tried the old (TGE) way, but...well...errors, errors, errors ;)We need a good workaround for that...what we need is at least the material name of the terrain piece the player currently walks on. That would be a good starting point to get this thing fixed...hopefully...
@Jacobin: commented out? yeah...and...completely removed *lol* Looks like GG have just disabled this feature for now...
Torque Owner Berserk