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

public class AsteroidSpawner : MonoBehaviour {

	[SerializeField] GameObject asteroid;
	BoxCollider box;
	Transform thisTF;
	void Start () 
	{
		box = GetComponent<BoxCollider> ();
		thisTF = GetComponent<Transform> ();
	}

	void Spawn () 
	{
		float point = -box.size.x /2;

		point += Random.Range (0f,102f);
		while (point < box.size.x / 2) 
		{
			float offest = Random.Range (-box.size.z / 2, box.size.z / 2);

			Instantiate (asteroid, thisTF.position + box.center + Vector3.right * point, thisTF.rotation);

			point += Random.Range (4f,102f);
		}

	}
}
