Advertisement
shadowplaycoding

P001_Galaxy

Apr 14th, 2017
1,026
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Galaxy : MonoBehaviour {
  5.  
  6.     // TODO: Have these values import from user settings
  7.     public int numberOfStars = 300;
  8.     public int maximumRadius = 100;
  9.  
  10.     // Use this for initialization
  11.     void Start () {
  12.  
  13.         for (int i = 0; i < numberOfStars; i++)
  14.         {
  15.             GameObject starGO = GameObject.CreatePrimitive(PrimitiveType.Sphere);
  16.  
  17.             float distance = Random.Range(0, maximumRadius);
  18.             float angle = Random.Range(0, 2 * Mathf.PI);
  19.  
  20.             Vector3 cartPosition = new Vector3(distance * Mathf.Cos(angle), 0, distance * Mathf.Sin(angle));
  21.  
  22.             starGO.transform.position = cartPosition;        
  23.  
  24.         }
  25.    
  26.     }
  27.    
  28.     // Update is called once per frame
  29.     void Update () {
  30.    
  31.     }
  32.    
  33.     /*
  34.         Copyright Shadowplay Coding 2016 - see www.shadowplaycoding.com for licensing details
  35.         Removing this comment forfits any rights given to the user under licensing.
  36.     */
  37.    
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement