using UnityEngine; using System.Collections; using Random = UnityEngine.Random; using System.Collections.Generic; public class Rotating_Quality : MonoBehaviour { public bool X_randomized = false; public bool Y_randomized = false; public bool Z_randomized = false; [SerializeField] public float x_speed = 30f; [SerializeField] public float y_speed = 30f; [SerializeField] public float z_speed = 30f; [SerializeField] public bool Rotate_on_x=true; [SerializeField] public bool Rotate_on_y=true; [SerializeField] public bool Rotate_on_z=true; void Start(){ if(X_randomized || Y_randomized || Z_randomized){ StartCoroutine(Variabil()); } } void Update (){ if(Rotate_on_x){ transform.Rotate(Vector3.up, x_speed * Time.deltaTime); } if(Rotate_on_y){ transform.Rotate(Vector3.right, y_speed * Time.deltaTime); } if(Rotate_on_z){ transform.Rotate(Vector3.forward, z_speed * Time.deltaTime); } } private IEnumerator Variabil() { if(X_randomized){ x_speed+=Random.Range(-8f,8f); if(x_speed<-120){ x_speed=-120; } if(x_speed>120){ x_speed=120; } } if(Y_randomized){ y_speed+=Random.Range(-8f,8f); if(y_speed<-120){ y_speed=-120; } if(y_speed>120){ y_speed=120; } } if(Z_randomized){ z_speed+=Random.Range(-8f,8f); if(z_speed<-120){ z_speed=-120; } if(z_speed>120){ z_speed=120; } } yield return new WaitForSeconds(0.1f); StartCoroutine(Variabil()); } }