Music Randomization

0 favourites
  • 5 posts
From the Asset Store
6 looping tracks to use in your games and projects. These tracks are in the style of the 1960s detective movie genre.
  • The title pretty much says it all: I have say 5-7 different songs I want to have play randomly in the background as you play the game. I just have no clue how to get the music to play in a random order. If anyone know's a simple way of implementing this (I could settle for a complex way too) then that would be awesome. I've looked up a couple tutorials, but none of them either made sense or did what I was hoping for. Thanks!

  • You can name your music from Music_1 to Music_7.

    Then Play music by name:

    "Music_" & choose(1,2,3,4,5,6,7)

  • Perfect thank you!

    Is there anyway to get the game to play a random song, but then know not to play that song (or any other song) twice in a row?

  • as Maverick1912 said you can use that approach but it will repeat the songs, to make it random yet not repeating you have to keep track of last 2 or 3 songs that have been played then exclude them from the next list of random selection.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • legofreak689: You can have 3 variables like this:

    new_song: choose(1,2,3,4,5,6,7)

    song_Counter: to count the song was played.

    song_ID: store the ID of last played song.

    Each time you play a song you add 1 to that counter.

    If counter = 2 you switch to the next one but compare the song_ID.

    If new_song = song_ID: do random again.

    Else play that song and set the song_ID to new_song

    Cheers,

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)