Hello, I want to play random sound files on certain events. However, it looks like it`s a missing feature. Dug through some old forum posts and seems like writing JS codes is the only solution, those posts are pretty old though…anyone came across a better method?? Check out the old links…
Thanks taliour! This was going to be my approach. Do you have more details about how exactly to do this?
E.g. Can a variable be an array that contains the relative paths to each file? Or is it best to add each sound as an object in the scene, and then create an array of object names?
Yes, you did it!
The problem was not the pointer, but for not use a pointer in the SoundManager variable, when I do:
SoundManager sound_manager = game->GetSoundManager()
It creates a copy of the sound manager in the memory. But surely other code of GD, to update the sound manager and so, uses a pointer, the pointer to the original sound manager pointing to another memory block different than my variable. In other words, this sound_manager variable is useless.
To fix it, just save the…
Gruk
March 14, 2020, 4:41pm
2
Here’s a personal example:
Depends on how many files you have
2 Likes
it worked? I tried the same way something was wrong, let me try it again
Gruk
March 15, 2020, 5:06pm
4
Sure it works. The limitation from the links you posted is relating to using Random() inside the filenames.
1 Like