Hello my friends ! So chatgpt has knowledge about gdevelop from 2001 so you will have to help me, thanks in advance, for starters, I added mp3 music to resources, and I would like it to be played continuously and randomly in the game, and if possible, every time the player leaves the game so that information about which songs have already been played is saved so that after re-entering the game the next songs are played, those that have not been played yet, and so on and so forth, I will add that I really have a lot of songs, I hope you will help, best regards!!
Here’s a way to achieve what you’re after:
-
Install the Array Tools extension
-
Create the following variables (global if you play the songs across multiple scenes):
-
Use these events:
Note, the song names must be manually entered in the red error boxes in the play song actions. This is because GDevelop requires the link to the song in the action. You cannot use a variable to hold the music file name.
@MrMen
Thanks !!! Question : how to add shuffle array ?? I can’t find it
Music is playing but only in first scene , and like in picture : I dont know where to find shuffle array option
Shuffle array is in the Array Tools extension.
Ok, Thank you !! I go it , Can you tell me what to do to play music in every scene? Did I do something wrong? I’ve only been in GDevelop for 4 days , I switched from Unity here because scripts is black magic for me, besides, that what you helped me I would never have figured out on my own Thanks ! And sorry for my English
You’ll need the events on every scene.
The most efficient way is to use external events, and instead of scene variables, use global variables This is because otherwise the scene variables need to be declared on each scene.
Have a read of the Wiki I linked, and ask away if you have any questions.
@MrMen ok , it works! but , when the scene changed the same song started playing from the beginning , when in the next scene I uncheck “Stop music and sounds at the beginning of this scene” the music played from the previous scene plays but the same song starts playing a second time, i.e. 2 songs play at once with a delay of one
That’s because the variable “PlayNewSong
” is set to true at the start of the scene. You’ll have to decide on the music playing logic and adjust your events for that.
You could make the following changes and see if they help:
1 = remove action
2 = change condition to “Sound has stopped”
3 = change action to “Play a sound on a channel”. Make the channel number the same as what you choose in #2.