Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class rotation : MonoBehaviour
  6. {
  7.  
  8.     public List<Transform> objectTransforms = new List<Transform> ();
  9.  
  10.     public float radius = 1.3f;
  11.     public float MaxRadius = 5f;
  12.     public float speed = 15;
  13.     public float MaxSpeed = 90;
  14.     public float TimeLeft = 15;
  15.     float rotationChange;
  16.  
  17.    
  18.     void Start ()
  19.     {
  20.         radius = MaxRadius;
  21.         MaxSpeed = speed;
  22.     }
  23.  
  24.     void Update ()
  25.     {
  26.         if (TimeLeft >= 0) {
  27.             TimeLeft -= Time.deltaTime;
  28.             radius -= Time.deltaTime / TimeLeft;
  29.             speed += Time.deltaTime * Mathf.Clamp (speed, speed, MaxRadius);
  30.             rotationChange += Time.deltaTime * speed;
  31.             for (float i = 0; i < 360; i += 360 / (float)objectTransforms.Count) {
  32.            
  33.                 objectTransforms [(int)(i / (360 / (float)objectTransforms.Count))].localPosition =
  34.                 new Vector3 (radius * Mathf.Cos (Mathf.Deg2Rad * (i + rotationChange)), radius * Mathf.Sin (Mathf.Deg2Rad * (i + rotationChange)));
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement