Advertisement
teleias

Galaxy

Jan 13th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1.         float x;
  2.         float z;
  3.         float theta = 0;
  4.         float r = 4;
  5.         float rIncrement = 1;
  6.         List<Planet> planets = new List<Planet>();
  7.         do
  8.         {
  9.             if(Random.Range(0,10) <= 7)
  10.             {
  11.                 float t = Mathf.Deg2Rad*theta;
  12.                 Transform planet = Transform.Instantiate(PlanetPrefab) as Transform;
  13.                 x = Mathf.Sin(t)*r;
  14.                 z = Mathf.Cos(t)*r;
  15.                 planets.Add (p);
  16.  
  17.             }
  18.             theta += Random.Range(18, 36*5);
  19.             if(theta >= Mathf.PI)
  20.             {
  21.                 theta-=Mathf.PI;
  22.                 r+=rIncrement;
  23.                 if(r >= 50)
  24.                     rIncrement = -1;
  25.                 if(r <= 5)
  26.                     rIncrement = +1;
  27.  
  28.             }
  29.         }while(planets.Count < 50);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement