- Home /
Audio Score Trigger Help
Basically, I have four different game music clips that I want the game to cycle through, changing when you hit every 10,000 or so points. For some reason, the code I am working with will not get the music to play. The visible score variable is taken care of elsewhere in the script and is not important right now, it just goes up as you move farther in the game.
var cycle: int = 0;
var gameMusic1;
var gameMusic2;
var gameMusic3;
var gameMusic4;
var visibleScore;
var hiddenScore = 0;
var gameMusic = [gameMusic1, gameMusic2, gameMusic3, gameMusic4];
function Update () {
if (visibleScore >= hiddenScore + 10000 || visibleScore == 0)
{
audio.PlayOneShot(gameMusic[cycle]);
hiddenScore = visibleScore;
cycle++;
if (cycle == 4)
{
cycle = 0;
}
}
I don't know if my methodology is correct, so any suggestions would be great.
But where all these things happening? I mean, what function you are putting this in?
Sorry, its in the update function. For some reason it didnt copy in there, i'll put it in
The array definition is wrong in the script. Check it. And you haven't initialized the variable "visibleScore" anywhere, yet you are giving it in the condition, how is this possible? Check that too.
This script isnt the entire script, its part of the playerscript. And the visible score is taken care of elsewhere in the script. I'd post the entire playerscript, but its about 500 lines long
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Wierd error messages concerning audio play and pause? 1 Answer
Playing audio 1 Answer
How to Mute/Unmute audio while another audio plays? 1 Answer
Audio Help 0 Answers