Game Development Community

Slightly Improved engine sound for wheeled vehicles

by Bruce Wallace · in Torque Game Engine · 08/28/2002 (10:34 am) · 1 replies

Hello, I have been trying alot of things with the wheeled vehicle code and having fun doing it. For my simple wheeled vehicle based game(Yet untitled).

I Found the normal Just increasing volume of the engine a bit annoying so adding this simple change made alot of differance. So I thought I would share it with anyone who was interested.

This change takes place in wheeledVehicle.cc found at \torque\engine\game\vehicles

1. Back up your wheeledVehicle.cc(Incase you would want to revert to the way it worked before).

2. Remove the Read only properties of wheeledVehicle.cc

3. Open the file In your choice of editors and search for the function:
void WheeledVehicle::updateEngineSound(F32 level)

4. Add the following Bold line to the function as shown:
void WheeledVehicle::updateEngineSound(F32 level)
{
   if (mEngineSound) {
      alxSourceMatrixF(mEngineSound, &getTransform());
      alxSourcef(mEngineSound, AL_GAIN_LINEAR, level);
      [b]alxSourcef(mEngineSound, AL_PITCH, (level * 2));[/b]
   }
}
5. Recompile your executable and add Your engine sound to the script for your vehicle if you haven't done so already.

All this little snip does is modify the pitch of your engine by the level that is sent to the update function, but makes a vast improvement(I think anyhow).

You can change the (level * 2) to suit your sound. Maybe adding an engine pitch shift variable to the vehicle datablock would be a good Idea to tune your sound to your liking.


Hope someone finds this tip useful.

Bruce Wallace, "Monster".

Edit: Removed Inactive Link

#1
03/27/2003 (1:32 am)
Yes it's much better that way. Another improvement is to have 2 sounds, one for the engine which depends on the applied thrust, and one depending on the actual vehicle speed. Same stuff works fine for flying vehicles, you can have engine sounds + separate wind sounds to give you a sense of your current speed.