Tuesday, June 28, 2011

Play sound Once


To play a sound once during Update() use a boolean variable or instantiate a GameObject with an AudioSource with the same settings.
function Start() {
soundplayed = false;
 }

function Update ()
 {

 if (!soundplayed)
 {
  audio.PlayOneShot(blast);
  soundplayed = true;
 }
 ... }

No comments:

Post a Comment