Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Particle particle = new();
- int i = 0;
- while (i < 50)
- {
- i++;
- float a = (float)(random.NextDouble() * Math.PI * 2); // TAU is 2π
- float sin = (float)Math.Sin(a);
- float cos = (float)Math.Cos(a);
- float r = Enumerable.Range(0, 6)
- .Select(_ => (float)random.NextDouble())
- .Sum();
- r = Math.Abs(r / 3.0f - 1.0f);
- //Vector2 pos = new Vector2(cos, sin) * ((float)Math.Sqrt(0.3f) * 10.0f * r);
- Vector2 pos = Random.insideUnitCircle * 5;
- float centerDist = new Vector2(pos.x, pos.y).magnitude;
- float force = Mathf.Sqrt(centerMass / centerDist) * particleForce;
- Vector2 direction = new Vector2(pos.y, pos.x).normalized;
- Vector2 velocity = new Vector2(direction.x, -direction.y) * (force * particleForce);
- float noise = Mathf.PerlinNoise((pos.x + 1000) * 4, (pos.y + 10000) * 4);
- if (pos.magnitude > .3f && (noise > .8f || random.NextDouble() < .1f))
- {
- particle = new Particle
- {
- position = pos,
- velocity = velocity,
- mass = mass
- };
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement