- Home /
SOS. Box collider trigger for audio
have a presentation in a few hours, and im desperate. one of my scripts is acting up.
Basically a Box Collider is hit and audio and text come out.
var stringToEdit = " "; var showgui:int=0; var PlayClip:audio.Play;
function OnGUI () {
if (showgui==1){ // Make a multiline text area that modifies stringToEdit. stringToEdit = GUI.TextArea (Rect (10, 10, 300, 100), stringToEdit, 200);audio.Play(PlayClip); } }
function OnTriggerEnter(){ showgui=1; }
GUI came out but audio was messed up! Whats wrong?
Answer by Eric5h5 · May 10, 2010 at 04:48 AM
That code wouldn't actually compile anyway; maybe you wanted something more like this:
var stringToEdit = " "; var showgui = false; var playClip : AudioClip;
function OnGUI () { if (showgui) { // Make a multiline text area that modifies stringToEdit. stringToEdit = GUI.TextArea (Rect (10, 10, 300, 100), stringToEdit, 200); } }
function OnTriggerEnter(){ showgui = true; audio.clip = playClip; audio.Play(); }
OnGUI runs at least twice per frame, so it's unlikely you want audio.Play() in there.
Thanks so much!! That actually made sense. Do you happen to know how to 'untrigger' the gui. cuz it just stays there thruout the game now.