I don't need to test my programs. I have an error-correcting modem.

Difference between revisions of "Legacy:TriggeredAmbientSound"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
m
(bStatic problem?)
Line 1: Line 1:
{{classbox| [[Legacy:Actor|Actor]] >> [[Legacy:Keypoint (UT)|Keypoint (UT)]] >> TriggeredAmbientSound}}
+
{{classbox| [[Legacy:UT|UT]] :: [[Legacy:Actor|Actor]] >> [[Legacy:Keypoint (UT)|Keypoint (UT)]] >> TriggeredAmbientSound}}
  
 
One of the Great Mysteries of Unreal I and UT: how to get this to work...?
 
One of the Great Mysteries of Unreal I and UT: how to get this to work...?
Line 118: Line 118:
 
</uscript>
 
</uscript>
  
==Related Topics ==
+
==Related Topics==
 
* [[Legacy:Triggering Sounds|Triggering Sounds]] covers the various workarounds
 
* [[Legacy:Triggering Sounds|Triggering Sounds]] covers the various workarounds
 
* [[Legacy:Embedding Code|Embedding Code]] explains how to add custom classes to a map
 
* [[Legacy:Embedding Code|Embedding Code]] explains how to add custom classes to a map
  
==Comments ==
+
==Discussion==
  
 
'''GTD-Carthage:''' Hey, has there been any update here? :o Looks like this is one unsolved problem...
 
'''GTD-Carthage:''' Hey, has there been any update here? :o Looks like this is one unsolved problem...
 +
 +
'''SuperApe:''' The bStatic problem?  I have a thought about this, although I'm not a UT person.  The bStatic problem could be solved with a special Trigger, like the VolumeTrigger is able to toggle bStatic Volumes.  The custom Trigger function can simply search for TrigAmbSound actors with the matching Tag and call <u>the TrigAmbSound's</u> Trigger function.
 +
 +
[[Category:Legacy Class (UT)|{{PAGENAME}}]]

Revision as of 12:50, 24 January 2006

UT :: Actor >> Keypoint (UT) >> TriggeredAmbientSound

One of the Great Mysteries of Unreal I and UT: how to get this to work...?

It seems problem #1 is Advanced -> bStatic needs to be set to false. However, there are reports that this still doesn't fix it.

Several coders have made their own versions:

Extending

YoMammy: (04/11/2002)

Advanced -> bStatic IS the problem with the TriggeredAmbientSound. On and above that, the TAS was likely coded up rather quickly for a specific purpose and therefor leaves lots to be desired.

For you sounding pleasure, however, I coded up a much better (if I do say so myself :) ) TAS. Here's a list of its new properties and one other parent property setting worth mentioning:

TrigAmbSound properties:

  • var() sound StartSound;
  • var() sound AmbSound;
  • var() sound StopSound;
  • var() bool bInitiallyOn;
  • var() float AmbDuration;
  • Object/InitialState TriggerToggle or TriggerControl (latter is default)

"StartSound" is where you can optionally place a one-shot sound. This will play when the TAS is triggered. Thereafter, if you specified an "AmbSound" (preferrably a looping sound), it will then play until you untrigger. Once untriggered, if you specified a "StopSound", that will play to finish things up.

"bInitially" should only be set to True if you set Object/InitialState = TriggleToggle. When doing this, the "StartSound" is bypassed and the process proceeds to the "AmbSound"...if any was specified.

If you set "AmbDuration" to anything other than it's default 0.0, the looping ambient sound specified in "AmbSound" will only play for the duration specified. Thereafter, things will work as normal...i.e. you'll still get the "StopSound" when untriggering.

If you want the script, get it here: http://www.gentekcom.com/~diinc/UTMaps/TrigAmbSound.u

In UEd, You'll find it under KeyPoint (where you'd expect). Open up the script and look at it...its rediculously simple. Now, forgive me for being a smartass, but isn't THIS what you'd expect a TriggeredAmbientSound to do in the first place?

CoolDude: Too bad, the link above seems to be broken. If anybody has a working one, please add it.

2001

Tarquin: I tried a search of my UT folder for anything with the name "TrigAmbSound" and found this in both a map called DM-2001][ by Wayne Young (AKA Slartybartfast) and wdy_mods.U (whatever that is!) The 'OnWhileTriggered' state sounds like it corresponds to 'TriggerControl' described above. I don't know if it's coincidence that it uses the same name, or if it's an earlier version. If anyone feels like contacting this guy and asking him if we can alter his script & improve it, his website is http://www.ganimede.demon.co.uk/ (and he works for nVidia).

//=============================================================================
// TrigAmbSound.
//=============================================================================
class TrigAmbSound extends Keypoint;
 
// Re-plays a sound effect if triggered.  If in state TriggerToggled,
// the sound is turned off if triggered, and turned on, etc..
// when triggered again.  In the OnWhileTriggered state, the instigator
// must stay within the trigger's radius for the sound effect to continue
// playing.  bInitiallyOn determines if the sound is playing from the 
// start, and does not apply in the OnWhileTriggered state.
 
var() sound StartSound; // Hmmm. This doesn't do anything yet :(
var() sound LoopSound;
var() sound EndSound;
var() bool  bInitiallyOn;
 
var	  bool  bIsOn;
 
function BeginPlay ()
{	
  if (bInitiallyOn) {
//    if (StartSound != None) {
//	  PlaySound (StartSound, , Float(SoundVolume)/128, , Float(SoundRadius)*25);
//	  }
    if (LoopSound != None) {
	  PlaySound (LoopSound, , Float(SoundVolume)/128, , Float(SoundRadius)*25);
	  }
    bIsOn = true;
    }
}
 
state() TriggerToggled
{
  function Trigger( actor Other, pawn EventInstigator )
	{
	bIsOn = !bIsOn;
	if (bIsOn) {
//      if (StartSound != None) {
//	    PlaySound (StartSound, , Float(SoundVolume)/128, , Float(SoundRadius)*25);
//	    }
      if (LoopSound != None) {
        PlaySound (LoopSound, , Float(SoundVolume)/128, , Float(SoundRadius)*25);
        }
	  }
	else {
      if (EndSound != None) {
        PlaySound (EndSound, , Float(SoundVolume)/128, , Float(SoundRadius)*25);
        }
	  }
	}
}
 
state() OnWhileTriggered
{
  function Trigger( actor Other, pawn EventInstigator )	{
    bIsOn = true;
//    if (StartSound != None) {
//	  PlaySound (StartSound, , Float(SoundVolume)/128, , Float(SoundRadius)*25);
//	  }
    if (LoopSound != None) {
      PlaySound (LoopSound, , Float(SoundVolume)/128, , Float(SoundRadius)*25);
      }
	}
 
  function UnTrigger( actor Other, pawn EventInstigator ) {
    bIsOn = false;
    if (EndSound != None) {
      PlaySound (EndSound, , Float(SoundVolume)/128, , Float(SoundRadius)*25);
      }
    }
 
Begin:
	bIsOn = false;
}

Related Topics

Discussion

GTD-Carthage: Hey, has there been any update here? :o Looks like this is one unsolved problem...

SuperApe: The bStatic problem? I have a thought about this, although I'm not a UT person. The bStatic problem could be solved with a special Trigger, like the VolumeTrigger is able to toggle bStatic Volumes. The custom Trigger function can simply search for TrigAmbSound actors with the matching Tag and call the TrigAmbSound's Trigger function.