craftworkgames / MonoGame.Extended

Extensions to make MonoGame more awesome
http://www.monogameextended.net/
Other
1.44k stars 325 forks source link

Fix ParticleEmitters always using same random seed #717

Closed mikeparker closed 3 years ago

mikeparker commented 3 years ago

Problem

Right now, every ParticleEmitter generates the same random spread of particles. This isn't so noticeable with lots of particles but with a low number (e.g. 5 particles in a spurt) it's very noticeable.

This is because the default FastRandom constructor initialises with a seed of 1.

Fix

This simply initialises the FastRandom with a random seed used by generating a new guid. We must use Math.Abs because FastRandom only accepts positive integers for the seed.

mikeparker commented 3 years ago

Looks like Profile class has the same problem. I'm getting identical patterns from profiles.

lithiumtoast commented 3 years ago

Looks like Profile class has the same problem. I'm getting identical patterns from profiles.

If you figure it out I be open for a PR :)