using UnityEngine;

public class Rotate : MonoBehaviour
{
    private float speedX;
    private float speedY;
    private float speedZ;

    [SerializeField] public Rigidbody rb;


    void Start()
    {
        speedX = Random.Range(-1f, 1f) * 100;
        speedY = Random.Range(-1f, 1f) * 100;
        speedZ = Random.Range(-1f, 1f) * 100;
    }

    // Update is called once per frame
    void Update()
    {
        transform.Rotate(speedX * Time.deltaTime, speedY * Time.deltaTime, speedZ * Time.deltaTime);
        if (transform.position.y < -6)
        {
            ChangePosAndRotation();
        }
    }

    void ChangePosAndRotation ()
    {
        transform.position = new Vector3(Random.Range(-7f, 7f), Random.Range(5f,10f), Random.Range(-1f, 6f));
        rb.linearVelocity = new Vector3(0, 0, 0);
        speedX = Random.Range(-1f, 1f) * 100;
        speedY = Random.Range(-1f, 1f) * 100;
        speedZ = Random.Range(-1f, 1f) * 100;
    }
}
