I’m working on a multiplayer where I need to create enemies in the same sequence as master.
So I thought of using Random.seed. At start I will sync the seed value expecting the whole game will use the same seed. The enemies positions are created runtime randomly using the same seed set at start.
I tried printing the seed value in update , it keeps changing. I don’t have any other part of the code that uses/sets seed.
Anything I’m missing in this?
Here is the scene for check. After calling Random.value, the seed is getting changed! very weird!
Please check the RandomGenerationTest scene in the package
Well maybe you just dont understand the purpose of Random.seed.
It is used to prevent the probably same gameplay if for example the Random.value is called at the beginning of the game everytime.
And yes, as the documentation says it changes everytime you call Random.value. It is intended behaviour: “The seed is normally set from some arbitrary value like the system clock before the random number functions are used.”
If you would like to use the same random numbers at both sides sync the Random.value each time you call it.
Yes, it’s intentional that Random.seed changes whenever you get a random value, otherwise Random.value would just return the same value every call, which is obviously useless. The whole point of Random.seed is that the sequence is the same every time, given a particular value.