PlayAllStoppedAmbientSoundsOnce([optional] string exception_1, [optional] string exception_2,..., [optional] string exception_n)
This function plays all stopped ambient sounds once except for the stopped ambient sounds sent to the function.
[optional] string exception_1, [optional] string exception_2,…, [optional] string exception_n
Specifies the name of the stopped ambient sounds that should not be played by this function. If no name is passed to PlayAllStoppedAmbientSoundsOnce function, all stopped ambient sounds will be played once.
function OnTriggerEnter(otherActorName) --nil means main character controller if otherActorName == nil then StopAllAmbientSounds() end end function OnTriggerStay(otherActorName) end function OnTriggerExit(otherActorName) if otherActorName == nil then PlayAllStoppedAmbientSoundsOnce("ambient2", "ambient3") end end
Assume that the above script is attached to a trigger named trigger1. Also assume that “ambient2” and “ambient3” are ambient sound objects.
Whenever the main character enters “trigger1”, all the ambient sounds that are playing will be stopped. When the main character exits “trigger1”, all the stopped ambient sounds except the ambient sounds “ambient2” and “ambient3” will be played once.PlayAllStoppedAmbientSoundsOnce