Buddy is the quest before this script should execute. When the quest is over, it’s supposed to play a ‘subsound’ after 5 seconds. However, this sonud just plays a million times.
#pragma strict
var brunoSound : AudioClip;
public var pissed;
function Update () {
//DO THIS IF YELLING AT BUDDY IS TRUE
if (Buddy == true); WaitForSeconds(5); { audio.PlayOneShot(brunoSound); }
var Buddy = false;
//SUBSOUND
if (Buddy == false); var pissed = true;
}
You’re killing your if statement by ending it with a semi-colon. also, the order in which you’re doing things is incredibly wrong, on line: 5 of your poorly formatted code, you’re saying, if Buddy is true - END STATEMENT - then it yields for 5 seconds, then it plays audio, etc etc. You’re also doing it below on line 8. You’re also redefining variables(like pissed) in the update function. Buddy isn’t defined whatsoever out of the function but between if statements, this code would explode.
var Buddy = false;
var brunoSound : AudioClip;
public var pissed;
function Update () {
if (Buddy == true)
{
WaitForSeconds(5);
audio.PlayOneShot(brunoSound);
}
if (Buddy == false) {
pissed = true;
}
}