Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class rotation : MonoBehaviour
- {
- public List<Transform> objectTransforms = new List<Transform> ();
- public float radius = 1.3f;
- public float MaxRadius = 5f;
- public float speed = 15;
- public float MaxSpeed = 90;
- public float TimeLeft = 15;
- float rotationChange;
- void Start ()
- {
- radius = MaxRadius;
- MaxSpeed = speed;
- }
- void Update ()
- {
- if (TimeLeft >= 0) {
- TimeLeft -= Time.deltaTime;
- radius -= Time.deltaTime / TimeLeft;
- speed += Time.deltaTime * Mathf.Clamp (speed, speed, MaxRadius);
- rotationChange += Time.deltaTime * speed;
- for (float i = 0; i < 360; i += 360 / (float)objectTransforms.Count) {
- objectTransforms [(int)(i / (360 / (float)objectTransforms.Count))].localPosition =
- new Vector3 (radius * Mathf.Cos (Mathf.Deg2Rad * (i + rotationChange)), radius * Mathf.Sin (Mathf.Deg2Rad * (i + rotationChange)));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement