Game Development Community

Triggered sounds

by Joshua Dixon · in Torque Game Engine · 11/20/2005 (9:00 pm) · 6 replies

Hi everyone,

First off, I'd like to do abit of kissin up and thank GG for an absolutely wonderful technology product.

The Torque Engine and the community surrounding GG is enabling me(a self taught hobbyist) to start work on my own vision of what I'd like in a game. The community support and the user and staff submitted resources are great and have saved me loads of trouble already.

Just thought I'd go ahead and get that out of me(yeah I been reading and toying with code non stop for days and the excitement hasn't left yet).

Ok now on to a little trouble I'm having(still getting used to where everythings at, but I'm learning a bit at a time).

I've looked around the docs and resources but cannot seem to find the information to correct this particular problem. Found some that got me close to an answer but not one yet unfortunately.

I have implimented several modifications to the engine itself and my compiles are still(supriseingly enough) going off with no warnings. One of these is a modified version of the Jetpack resource. Of course I had to modify some of it to suite me, but the overal programming remains the same.

What I'd like to do is have it so that when the "jet" action is activated, to play a rumble sound. I have a sound already converted to .ogg and it's in my data/sounds directory.

datablock AudioProfile(JettingSound)
{
filename = "~/data/sound/rumble.ogg";
description = AudioClosestLooping3d;
preload = true;
};

Now this is where I'm running into trouble.

I have read some of the threads about triggering a a sound, but there seem to be several ways of doing this depending on what the type of sound is. Whether it's ambient or whether the player triggers it by clicking on it or getting near it. All of them seem to be different and none of them fit what I need since the even I would like is an action triggered by the movement or event of the player.

If anyone knows where I might find usefull information or a resource that fits this(I've tried everywhere), I'd be most greatfull.

Thanks in advance,
Josh

#1
11/21/2005 (5:32 am)
You could hack something up in script, but I'd recommend making a backup of what you have and taking a look at the vehicle source files, the vehicles still have code for playing jetting sounds.

I just did a text search to verify that the code is still there, search for "jetSound", that should get you started.
#2
11/21/2005 (4:14 pm)
Thats great, I found the jetSound code already. And I already see what you were talking about.

I was unsure if this could or even should be linked in script. But since I found this, this will get me started on writing the sounds per action that I wanted.

Thanks
#3
11/21/2005 (5:56 pm)
Having a tad of trouble here, let me show you what I have and maybe someone can point this out.

Jetting + Sound code from player.cc
//==================================================
	// Jetting
	//==================================================
	if (move->trigger[1] && !isMounted()) {   
		if (!mJetting && mEnergy  >= mDataBlock->minJumpEnergy)   {      
			mJetting = true;  
			
		}
		if (mJetting)   {      
			F32 newEnergy = mEnergy - mDataBlock->minJumpEnergy;     
			if (newEnergy < 0)      {   
			if (!mDataBlock->sound[PlayerData::JetpackSound])
				  return;
			   if (!mJetting) {
				  if (mJetpackSound) {
					 alxStop(mJetpackSound);
					 mJetpackSound = 0;
				  }
			   }
			   else {
				  if (!mJetpackSound)
					 mJetpackSound = alxPlay(mDataBlock->sound[PlayerData::JetpackSound], &getTransform());

				  alxSourceMatrixF(mJetpackSound, &getTransform());
			   }
				newEnergy = 0;  
				mJetpackSound = 0;       
				mJetting = false;      
				}      mEnergy = newEnergy;   
		}
	} else {   
		mJetting = false;
	}
	if (mJetting) {  
		acc.z += (mDataBlock->jumpForce / mMass) * 5 * TickSec;
	}
0 Errors or warnings. Compiles fine.

I open up the game, hit start mission and she crashes.

I've looked over and adjusted the code several times to little effect, same thing happens everytime.
#4
11/21/2005 (8:23 pm)
Anyone have a suggestion for someplace I can look this up or what I have wrong?
#5
11/21/2005 (9:04 pm)
Check your console.log, you might find an answer to your problem in there..
#6
11/21/2005 (9:27 pm)
Edit: Update

Traced the problem back to this,

addField("JettingSound", TypeAudioProfilePtr, Offset(sound[JetpackSound], PlayerData));

Not sure why, but as soon as I comment this out, it will load fine and everything works(except the sound of course).