I am using Unity 3.5.7
In my Awake method I set Random.seed = 1.
In a method that gets called by OnTriggerEnter I use Random.Range(1, 5).
My problem is that setting the seed in the awake has no effect, it is always ‘random’ I never get the same random set of values.
But when I use the random.Range in the same method as setting the seed, I do get the same results:
void Awake()
{
Random.seed = 1;
Random.Range(1, 5);
Random.Range(1, 5);
Random.seed = 2;
Random.Range(1, 5);
Random.Range(1, 5);
Random.seed = 1;
Random.Range(1, 5);
Random.Range(1, 5);
}
Am I missing something?
UPDATE:
It seems the seed is affected by time. When I start a co routine wich waits 1 sec and then outputs four random numbers with a seed of 2 I get:
2
3
3
1
But When I wait for one second then set the seed and wait 1 sec between the random numbers I get:
2
1
3
1
This is always the same, but when there is time between them it changes. Is there a way around this or do I have to create my own seed system?