Game Development Community

Vehicle Ignition System Sound problems

by Ronald J Nelson · in Torque Game Engine · 12/19/2005 (9:10 am) · 4 replies

I need to find out how to kill the engine sound and start it up again with my ignition switch code. I have it so it disables input and basically the car is dead. But my problem is the engine sound just keeps going. Help please.

#1
12/19/2005 (9:44 am)
You will need to use the schedule function to switch between the "dead" state to the "starting" state and finally to the "running" state. If I went into it fully I would be practically writting your code, but you shyould be able to get the idea. You will want to keep track of the audio profile you use for the start sound, and stop that when you switch to running and then play the running sound.

Hope that helps a little.
#2
12/19/2005 (9:54 am)
alxStop($CarHandle);

That's the command you want. Your audio should be set up as below for it to work.

In client/scripts/audioprofiles.cs at the top add $CarAudioType = 4;, it should look like this...

$GuiAudioType     = 1;
$SimAudioType     = 2;
$MessageAudioType = 3;
[b]$CarAudioType   = 4;[/b]

In server/scripts/audioprofiles.cs add your profiles...

datablock AudioProfile(carEngineSound)
{
   filename    = "~/data/sound/vehicles/buggy/engine_idle.wav";
   description = EngineSound;
   preload = true;
};

datablock AudioDescription(EngineSound)
{
   volume   = 1.0;
   isLooping= true;

   is3D     = true;
   ReferenceDistance= 10.0;
   MaxDistance= 50.0;
   type     = $CarAudioType;
};

That's it, when you call the alxStop($carHandle); command (from console or script) your sound will stop. To play it again you'll want to use $carHandle = alxPlay(carEngineSound);

That's the best i could give you given the lack of information on your behalf.
#3
12/19/2005 (10:01 am)
Thank you very much!
#4
12/19/2005 (10:05 am)
Pleasure, glad you got it working.