Advertisement
JontePonte

particle yeye

Nov 18th, 2024
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1.  Particle particle = new();
  2.         int i = 0;
  3.         while (i < 50)
  4.         {
  5.             i++;
  6.             float a = (float)(random.NextDouble() * Math.PI * 2); // TAU is 2π
  7.             float sin = (float)Math.Sin(a);
  8.             float cos = (float)Math.Cos(a);
  9.  
  10.             float r = Enumerable.Range(0, 6)
  11.                 .Select(_ => (float)random.NextDouble())
  12.                 .Sum();
  13.  
  14.             r = Math.Abs(r / 3.0f - 1.0f);
  15.                
  16.             //Vector2 pos = new Vector2(cos, sin) * ((float)Math.Sqrt(0.3f) * 10.0f * r);
  17.             Vector2 pos = Random.insideUnitCircle * 5;
  18.             float centerDist = new Vector2(pos.x, pos.y).magnitude;
  19.             float force = Mathf.Sqrt(centerMass / centerDist) * particleForce;
  20.             Vector2 direction = new Vector2(pos.y, pos.x).normalized;
  21.             Vector2 velocity = new Vector2(direction.x, -direction.y) * (force * particleForce);
  22.            
  23.             float noise = Mathf.PerlinNoise((pos.x + 1000) * 4, (pos.y + 10000) * 4);
  24.             if (pos.magnitude > .3f && (noise > .8f || random.NextDouble() < .1f))
  25.             {
  26.                 particle = new Particle
  27.                 {
  28.                     position = pos,
  29.                     velocity = velocity,
  30.                     mass = mass
  31.                 };
  32.                 break;
  33.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement