Game Development Community

3D sound in TGB ?

by Dirk Hoffmann · in Torque Game Builder · 07/12/2008 (9:17 am) · 5 replies

Hello,

Someone, who knows how to "attach" a sound to a TGB object like a sprite, so that the sound of an enemy raises if the player comes closer to it ?

I tried:

new AudioDescription(AudioLooping3D)
{
volume = 1.0;
isLooping= true;
is3D = true;
ReferenceDistance =2.0;
MaxDistance = 10.0;
type = $GuiAudioType;
};

new AudioProfile(Breedersound)
{
filename = "~/data/audio/PowDow2.ogg";
description = "AudioLooping3D";
preload = true;
};


Then, in the 'onLevelLoaded' for the object I did:

%this.playAudio(0,Breedersound);



It doesn't work in the way, that is doesn't play the sound at all.

#1
07/12/2008 (3:14 pm)
Without knowing what "3D sound" is, when I try what you've got I receive an "Unknown command playAudio" error.

In the Breakout tutorial, the commands used are
$sound = alxPlay(Breedersound)
and
alxStop($sound)
#2
07/12/2008 (7:18 pm)
Mount a trigger object to the enemy. When the player enters the trigger play the sound!
#3
07/13/2008 (4:27 am)
Hello,

I'll catch the Trigger possibility, even knowing I have a switched on/off (0/1) solution and no sustaining sound, Thanx.

But still my question, isn't there the possibility of something like sound emitter in TGB ?

Thank you
Dirk
#4
07/13/2008 (3:07 pm)
There isn't (to my knowledge) a sound emitter type object for TGB.

But you can basically make one in script with a trigger object. It doesn't have to be a 0/1 volume sound. For a "play-once" sound you can set the volume when you play it based on the distance to the trigger object (center point), and for a looping sound you could continuously update the sound volume (while within the trigger).
#5
07/20/2008 (9:28 pm)
I just noticed that SoundProfile does have a "is3D" field, and alxPlay does take a position argument (for playing 3D sounds). So... the question is, does this still work in TGB and if so, is the "listener" at position "0 0 0", does it still take 3D positions since this is likely legacy code from TGE. I don't know the answers but something you might investigate.