Play 3D sound
by Blackcode · in Torque Game Engine · 05/30/2007 (8:33 am) · 1 replies
When I use the following code the engine crashed, any idea ?
%whichdoor.openSnd = %whichdoor.playAudio(0, doorStartOpenSwingSnd);
//sound proifle
datablock AudioProfile(doorStartOpenSwingSnd)
{
fileName = "~/data/sound/door1_move.wav";
description = AudioOpen3d;
preload = true;
};
thanks
%whichdoor.openSnd = %whichdoor.playAudio(0, doorStartOpenSwingSnd);
//sound proifle
datablock AudioProfile(doorStartOpenSwingSnd)
{
fileName = "~/data/sound/door1_move.wav";
description = AudioOpen3d;
preload = true;
};
thanks
Torque 3D Owner mb
Create a new audio description & audio profile: client/audioProfiles.cs
datablock AudioDescription(OpenDoorDescription) { volume = 1.0; isLooping= false; is3D = true; ReferenceDistance= 20.0; MaxDistance= 100.0; type = $SimAudioType; }; datablock AudioProfile(OpenDoorProfile) { filename = "~/data/sound/door1_move.wav"; description = "OpenDoorDescription"; preload = true; };Then on the clientside add a function to play your sound: client/game.cs
function clientCmdPlayDoorSound() { $doorSound = alxPlay(OpenDoorProfile); }Now use a command to client to play the sound when you need to: (where %cl is the clientID)
or you could make it a function and call it .... something like:
function startDoorSound() { // Tell the client to count. for( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ ) { %cl = ClientGroup.getObject( %clientIndex ); commandToClient(%cl, 'PlayDoorSound'); } }(edit)
Then when you need to stop the sound you can then use: