Play during first loop, probability for loops afterwards

Hi everyone!

I’m working on a game where I have different loops that either well, loop, or hop between each other. Each section of music may loop on itself, or it may hop to another section of music, that may loop or hop to another one or back to the first one, etc. As you pass certain checkpoints, a new track is added to each loop (these checkpoints are parameters). I’d like to make it so that after you pass a checkpoint, the first time you hear a section of music, you always hear the new track that is added. If the section of music loops, said newly-added track has a probability of possible being heard, and possibly not.

Is there a way of doing this within FMOD studio itself, without having to add another parameter that would need to be integrated in Unity for the first time you pass a checkpoint? I tried nesting a multi instrument with the track and silence into a multi instrument that has the track and only plays once, but the timing got messed up- it needs to stay synced to the music. Maybe something with command instruments?

Thanks so much for your help!

No.

You want a change in your game’s state (whether the player has passed the checkpoint) to alter the behavior of the music event. You must therefore communicate this change in the game’s state to the music event somehow. There are exactly two ways to communicate a change in a game’s state to a playing event: Parameters and cues. You will need to use at least one of them.

Of these two, cues are more suitable for impulses (“something has happened and you should do something about it, but you don’t need to remember it afterwards”) and parameters are more suitable for permanent changes (“the player has passed the checkpoint, and you should remember that”). As such, parameters are the tool appropriate for your case.

As you have discovered, you can’t just rely on a time delay, because there’s no guarantee that the game’s state will change with the timing you specify. Your game has to send a message to the event, and parameters are the only appropriate of doing that.

Hi! Thanks so much for your help. I’m sorry if I wasn’t clear, but I already have a parameter in fmod that’s also already implemented in Unity for passing the checkpoints- that part of the system already works! I currently have it so that once you pass the checkpoint, the new track always plays. I also can change the probability so that it’ll play X% of the time, but that means there’s a chance it won’t play the first time you pass the checkpoint.

What I’d like to do, is have the new track play for sure the first time you hear the music, and if the music loops, have it be a probability that it might play, and it might not, for more variation. All of this info is internal to fmod from what I can tell- whether the track has already played or not.

Thanks! :slight_smile:

@joseph Just wanted to check in on this again, I realized I didn’t tag you before so I’m not sure if you got the notification I replied. Thanks so much! :slight_smile:

There is technically no way to do this - but you can come almost indistinguishably close to it.

  1. Replace each music track instrument with a multi instrument.
  2. Set each of the new multi instruments’ playlist selection modes to “sequential - play scope.”
  3. Make the first entry in the multi instrument’s playlist the instrument that the multi instrument is replacing.
  4. Make the second entry in the multi instrument’s playlist another multi instrument, which I’ll henceforth refer to as “the nested multi instrument.”
  5. Set the nested multi instrument’s playlist selection mode to “random.”
  6. Populate the nested multi instrument’s playlist with two instruments: One copy of the music instrument that the parent multi instrument replaced (i.e.: a copy of the instrument you added to the parent multi instrument back in step 3), and one silence instrument.
  7. Set the play percentages of the two instruments in the nested multi instrument’s playlist to whatever you need them to be.

This configuration will mean that the first time the parent instrument is triggered, it will definitely play the music track; but the second time, it will have whatever percentage chance of playing the track you specified in step 7.

Of course, this does mean that the parent instrument is guaranteed to play the track every second time it is triggered - but you can dilute that by copying and pasting the second entry in the parent multi instrument’s playlist multiple times; doing so will ensure that the parent multi instrument is only guaranteed to play the associated track every n times it’s triggered, where n is the number of entries in its playlist.

If you’re planning to do this for multiple different instruments, I recommend making the number of entries in each parent multi instrument’s playlist a different prime number, to reduce the chance of entries predictably playing at the same time with a specific frequency.

Don’t worry, this forum is integrated with our support ticketing system, so we automatically get notified any time anyone posts in a thread to which we have previously responded.