How do you play background music only in certain areas?
by Robert Geiman · in Torque Game Engine · 10/16/2005 (9:33 am) · 10 replies
I believe I got my AudioDescription and AudioProfile scripts setup to play my background music, but I don't want the music playing when the map first starts.
Instead, I want to define an area in my map where when the player enters it the music starts, and when they exit the music stops.
Anyone have any clues on how this could be done?
Instead, I want to define an area in my map where when the player enters it the music starts, and when they exit the music stops.
Anyone have any clues on how this could be done?
#2
Question though: How to I increase the size of the trigger to encompass a large area? In the World Editor it is just a small cube...
10/16/2005 (10:21 am)
Ah, thanks for the quick replay Dirk. Looks like this may be just what I need.Question though: How to I increase the size of the trigger to encompass a large area? In the World Editor it is just a small cube...
#3
10/16/2005 (10:25 am)
[url="http://www.garagegames.com/docs/tge/general/ch04s02.php"]Read the manual[/url] ;-).
#4
10/16/2005 (10:44 am)
Change the scale in the editor f3
#5
Yes, scale looks to be exactly what we need.
Thanks a lot guys!
10/16/2005 (11:16 am)
Ah, I looked at under the manual under Triggers, but they explain nothing except the tickPeriodMS field.Yes, scale looks to be exactly what we need.
Thanks a lot guys!
#6
To rotate, Alt with mouse
Dirkks code example looks nice, but I am missing something here. How does new AudioProfile(musicToPlay){filename=" " description=" "} (client/scripts/audioProfiles.cs) function fit in with Dirkk's code sample?
Is the TriggerMusic in the code sample same as my musicToPlay? How are the two .cs files tied together?
(In Dirkk's Code) $triggermusic = alxPlay(TriggerMusic);
In function- MusicTrigger::onEnterTrigger( %this, %trigger, %obj )
Maybe I'm asking the question a bit backwards, but I'm thinking that there needs to be a music channel in audioProfiles.cs attached here. :-)
Thanks, Tatjana
10/26/2005 (7:39 am)
To Change scale of triggers, Ctrl+Alt with mouseTo rotate, Alt with mouse
Dirkks code example looks nice, but I am missing something here. How does new AudioProfile(musicToPlay){filename=" " description=" "} (client/scripts/audioProfiles.cs) function fit in with Dirkk's code sample?
Is the TriggerMusic in the code sample same as my musicToPlay? How are the two .cs files tied together?
(In Dirkk's Code) $triggermusic = alxPlay(TriggerMusic);
In function- MusicTrigger::onEnterTrigger( %this, %trigger, %obj )
Maybe I'm asking the question a bit backwards, but I'm thinking that there needs to be a music channel in audioProfiles.cs attached here. :-)
Thanks, Tatjana
#7
The above code would work with his code sample (replace the fileName with one relevant to your music file, preferably in .wav format), you can place it at the top of the same script file you define the trigger in.
Maybe I misunderstood the question?
10/26/2005 (9:01 am)
TriggerMusic is just an audio profile... ex:new AudioDescription(ThemeMusic)
{
volume = 1.0;
isLooping = true; // false if you don't want profiles of this type looping
isStreaming = false;
is3D = false;
type = 2;
};
new AudioProfile(TriggerMusic) {
fileName = "~/data/sound/music.wav";
description = "ThemeMusic";
preload = true;
};The above code would work with his code sample (replace the fileName with one relevant to your music file, preferably in .wav format), you can place it at the top of the same script file you define the trigger in.
Maybe I misunderstood the question?
#8
This is what I was looking for.
Thanks so much,
Tatjana
10/26/2005 (6:25 pm)
Anthony, You Wonderful Person! :- )This is what I was looking for.
Thanks so much,
Tatjana
#9
Like how cars drive by in GTA with blasting music.
10/26/2005 (6:56 pm)
What about playing music thru an emitter attached to an object? Like how cars drive by in GTA with blasting music.
#10
12/04/2005 (1:10 pm)
I used the code stated above in tqe 1.4...for some reason i can not alter the volume from the editor...and i tried altering the volume level from my audio profile and that did nothing either...could someone suggest a way to alter the volume or get it to where i can alter it in the editor
Torque Owner Dirk "dirkk" Krause
It should look like this:
datablock TriggerData( MusicTrigger ) { tickPeriodMS = 100; }; function MusicTrigger::onEnterTrigger( %this, %trigger, %obj ) { echo( "Music started."); $triggermusic = alxPlay(TriggerMusic); Parent::onEnterTrigger( %this, %trigger, %obj ); } function MusicTrigger::onLeaveTrigger( %this, %trigger, %obj ) { echo( "Music stopped."); alxStop($triggermusic); Parent::onLeaveTrigger( %this, %trigger, %obj ); }