SHARE
TWEET

P001_Galaxy

shadowplaycoding Apr 14th, 2017 (edited) 197 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top