Quantcast
Channel: Questions in topic: "repeat"
Viewing all articles
Browse latest Browse all 137

Problem with triggering repeated audio on entry and ending it on exit from trigger

$
0
0
I am trying to set up a script that will trigger an audio clip when the First Person Controller Player enters a trigger zone described by a mesh collider. The mesh collider is set with Is Trigger checked true. The FPC is operating normally, and the audio clip is imported into my assets with no problem. I have been able to follow some C# and javascript examples to get the audio to trigger on entry to the trigger area, but I haven't been able to get it to loop or repeat continuously exactly until the FPC Player exits the collider. My problem seems to be closest to this one: http://answers.unity3d.com/questions/408115/play-audio-sources-in-trigger-zone-when-player-ent.html and I think I should be using OnTriggerEnter and OnTriggerExit. However, I haven't been able to figure out exactly how to trigger audio on entry, loop/repeat until exit, and turn it off on exit. I don't have multiple audio sources though, just a buzzer sound that should play continuously whenever the Player is located within a wedge-shaped mesh. The other scripts in my project are in C# so it would be great if someone could help me with a C# script, but any help would be appreciated!

Viewing all articles
Browse latest Browse all 137

Trending Articles