SHARE
TWEET

Planets.cs

a guest Dec 29th, 2015 134 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 Planet : MonoBehaviour {
  5.  
  6.     public Transform sun;
  7.     public float speed;
  8.  
  9.     public void Init(Transform _sun)
  10.     {
  11.         sun = _sun;
  12.  
  13.         if (Random.Range(1, 10) >= 5)
  14.         {
  15.             speed = Random.Range(-30, -0.000001f);
  16.         }
  17.         else
  18.         {
  19.             speed = Random.Range(30, 0.000001f);
  20.         }
  21.  
  22.         transform.GetComponent<Renderer>().material.color = new Color((int)Random.Range(0, 255), (int)Random.Range(0, 255), (int)Random.Range(0, 255));
  23.     }
  24.    
  25.     // Update is called once per frame
  26.     void Update () {
  27.         transform.RotateAround(sun.position, Vector3.up, speed * Time.deltaTime);
  28.     }
  29. }
RAW Paste Data
Top