using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AsteroidRandom : MonoBehaviour {

	Transform thisTF;
	Vector3 randRot;
	float randSpeed;
	[SerializeField] Mesh newMesh;
	[SerializeField] MeshFilter mesh;
	[SerializeField] MeshCollider col;
	void Start () 
	{
		thisTF = GetComponent<Transform> ();
		randRot = new Vector3 (Random.Range (-1f, 1f), Random.Range (-1f, 1f), Random.Range (-1f, 1f));
		randSpeed = Random.Range (2f, 10f);
		thisTF.position += Vector3.up * Random.Range (-1.3f, 1.3f);
		thisTF.rotation = Quaternion.LookRotation (new Vector3 (Random.Range (-1f, 1f), Random.Range (-1f, 1f), Random.Range (-1f, 1f)));
		if (Random.Range (0, 4) >= 3) {
			mesh.mesh = newMesh;
			col.sharedMesh = newMesh;	
		}
	}
	

	void Update () 
	{
		thisTF.RotateAround (thisTF.position, randRot, randSpeed * Time.deltaTime);
	}
}
