x


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.

more ▼

asked Apr 30 '12 at 12:42 PM

depento gravatar image

depento
1 1 1 3

But where all these things happening? I mean, what function you are putting this in?

Apr 30 '12 at 12:44 PM venkspower

Sorry, its in the update function. For some reason it didnt copy in there, i'll put it in

Apr 30 '12 at 12:47 PM depento

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.

Apr 30 '12 at 12:48 PM venkspower

This script wouldn't compile.

Apr 30 '12 at 12:49 PM venkspower

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

Apr 30 '12 at 12:50 PM depento
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2057
x1060
x38

asked: Apr 30 '12 at 12:42 PM

Seen: 295 times

Last Updated: Apr 30 '12 at 12:59 PM