I want to place triggers in the world, that play music, when the player is close to them.
I want to reuse the same MusicTrigger-object, but one of them will load songA.mp3 the other songB.mp3
Is it possible to give the MusicTrigger an object/instance variable FileName (Text): songA.mp3 and then in the load music action specify this variable as the file name?
As it is “Load Music” does not allow expressions. What could be a work-around?
@Ondaluce could you use the extension above for what you needed to do last week?
1 Like
Thanks for the heads-up. I solved the problem by also using this extension.
For anyone who wants to import hundreds of audio files at once and use variables to play them:
- You can edit the game’s JSON and add the audio files inside the “resources” field. Example:
"resources": [
{
"file": "AUDIO1.ogg",
"kind": "audio",
"metadata": "",
"name": "AUDIO1.ogg",
"preloadAsMusic": false,
"preloadAsSound": false,
"preloadInCache": false,
"userAdded": false
},
- In GDevelop, run a resource scan from the Resources panel.
- Finally, you can use this helpful extension to preload each track and then play it (thanks petlimpet for taking an interest!).
1 Like