using UnityEngine;
using System.Collections;
public class GeneratorEnemy : MonoBehaviour {
public GameObject enemy;
public int numberOfCubes =0;
public int min,max;
private float time = 0;
private int period = 5;
void Start()
{
PlaceCubes ();
}
void Update()
{
time += Time.deltaTime;
if (time >= period)
{
numberOfCubes ++;
PlaceCubes();
time = 0;
}
}
void PlaceCubes()
{
for (int i = 0;i <= numberOfCubes;i++)
{
Instantiate(enemy,GeneratedPosition(),Quaternion.identity);
}
}
Vector3 GeneratedPosition()
{
int x, y, z;
x = UnityEngine.Random.Range (min, max);
y = UnityEngine.Random.Range (250, 250);
z = UnityEngine.Random.Range (min, max);
return new Vector3 (x, y, z);
}
}
//how can i give speed to each object?