I’ve got a problem with my sound when it first plays. When the following code plays, the very first part of the sound is just a crackle, and I only hear the end of the sound. The same thing happens if I remove the “audio.Stop” line completely.
private var sound = 0;
private var soundPlayed : String;
var soundOne : AudioClip;
function Update (){
if (sound == 0 soundPlayed != "soundOne") {
audio.Stop();
audio.PlayOneShot (soundOne);
soundPlayed = "soundOne";
}
}
Bizarrely, if I alter the “audio.Stop” line like this, it plays the whole sound beginning to end, but this is obviously coded incorrectly and shows the coding error “Expressions in statements must only be executed for their side-effects”.
private var sound = 0;
private var soundPlayed : String;
var soundOne : AudioClip;
function Update (){
if (sound == 0 soundPlayed != "soundOne") {
audio.Stop;
audio.PlayOneShot (soundOne);
soundPlayed = "soundOne";
}
}
Please can anyone advise me how can I re-code this so that the whole of the sound file plays from beginning to end without missing out the very start of the sound file?