Game Development Community

Controlling Sound With Triggers

by Luke Hopkins · in Game Design and Creative Issues · 03/01/2010 (9:39 pm) · 3 replies

At the moment I am controlling when the audio though triggers.

new Trigger(EventTrigger01) {
canSaveDynamicFields = "1";
Enabled = "1";
position = "800.464 844.839 58.9535";
rotation = "1 0 0 0";
scale = "1 5.38 2.56";
dataBlock = "EventTrigger";
dataBlock = "EventTrigger";
polyhedron = "0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000";
category = "Triggers";
editorIcon = "tools/LogickingEditor/images/Trigger";
ignoreAI = "1";
onEnter = "Path01.speed = 0.1; CutScene01.play();missionMusic01.schedule(100, \"play\");";
templateName = "EventTrigger";

The audio is always looping however what i want to archive is that once you enter the next trigger. The audio stops looping and once the track has finished the next audio part loads.
I am not a strong scripter and was woundering if you guys could possible ponit me in the right direction on how i might do this.My second trigger looks like this;

new Trigger(EventTrigger02) {
canSaveDynamicFields = "1";
Enabled = "1";
position = "773.794 843.828 59.0087";
rotation = "1 0 0 0";
scale = "1 8.12 2.41";
dataBlock = "EventTrigger";
dataBlock = "EventTrigger";
polyhedron = "0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000";
category = "Triggers";
editorIcon = "tools/LogickingEditor/images/Trigger";
ignoreAI = "1";
onEnter = "missionMusic01.isLooping = false; CutScene01.playSound();Path01.speed = 10; CutScene01.play(); "
templateName = "EventTrigger";
};


So what im trying to do here is "missionMusic01.isLooping = false" to stop the audio piece looping and then Cutscene.playSounds has

if ( %this != %currTrackSource )
return;

if ( %status $= "stopped" )
playNextTrack();
What i want this to do is once the track has stopping start the new track.

However, i am failing to see any progress and i knonw some of my script is wrong. I was woundering if you guys could shine any light on this for me.

Thank You
L

#1
03/02/2010 (5:19 am)

Which engine are you using? TGE or TGEA?

I am assuming the same goes for TGE's audio system, but SFX in TGEA does not provide means to stop looping like this. The "isLooping" field on SFXDescriptions is read once when the sound is initialized. From then on, the sound is either looping infinitely or not looping at all.
#2
03/02/2010 (9:12 am)
Sorry Im using TGEA with GMK. That would explain why once i change it to looping = false nothing happens. Is there any way to have a counter so once its played so many times it stops?
#3
03/02/2010 (1:16 pm)
Stock SFX has no means to set the number of loops. Without engine modifications, this can only be worked around with some scripting trickery (e.g. monitoring the play cursor).

One problem for SFX here is that not all APIs actually support numbered loops (OpenAL does not).

Adding the ability to turn off looping on an existing source would be pretty trivial though //Edit: except for the change having to be propagated to all SFX devices of which I didn't think; that's messy.