My game must be deterministic, but I’m having problems running my tests in the same machine (!).
We are using .NET Math and Random (always same seed, of course), and that can be a reason why I lose determinism in different machines. Is that true? Does Unity assure the same results on different machines if I use Mathf and Unity.Random?
I’m doing everything on FixedUpdate, so any clues of why I’m losing determinism in the same machine would be great.
My checksum simply sums x,y,z of the position of my main GameObjects.
Both System.Math.Random and UnityEngine.Random are platform/machine independent. Assuming you give it the same seed each time, every build of your game on every platform will produce the same random sequence. If you still don’t see deterministic results, something is amiss in your code (seeding, race conditions, flow differences, etc). Here are the diffs that I know of… and reasons why I prefer UnityEngine.Random for game code.
UnityEngine.Random has static functions / properties. Any time you need a random number, just use UnityEngine.Random.value. System.Math.Random is a regular class that must be instantiated and stored by any classes trying to use it.
UnityEngine.Random produces floats, System.Math.Random produces ints or doubles.