Setting random seed


(Jason Ericson) #1

It seems that the randomizer in FMOD Studio is producing the same results every time I play the game (or even test it out in Studio). Is there any way to seed it so that I get different results every time? I’m using the Unity integration, I don’t know if that changes anything.


(Nicholas Wilcox) #2

Set the seed through the low level advanced settings structure before the system is initialized.

In the Unity Integration add this snippet at in FMOD_StudioSystem.Init() before it calls system.initialiaze()

FMOD.ADVANCEDSETTINGS advancedsettings = new FMOD.ADVANCEDSETTINGS();
long seed = global::System.DateTime.Now.ToBinary();
advancedsettings.randomSeed = ((uint)seed) ^ ((uint)(seed >> 32));
FMOD.System lowlevel;
ERRCHECK(system.getLowLevelSystem(out lowlevel));
ERRCHECK(lowlevel.setAdvancedSettings(ref advancedsettings));