Hi Guys,
var enemySlot: GameObject;
var spawn1 : GameObject;
var spawn2 : GameObject;
var spawnTime = 70.0;
var Xenemies : int; // to define how many enemies i wish to clone in each
//spawn period
function Update ()
{
InvokeRepeating("spawn", .01, spawnTime);
}
function spawn()
{
var time : int = Time.realtimeSinceStartup * 1000;
if((time & 0x01) == 0) //Checking if the time millisecond count is an even number(To make it come out of random side)
{
Instantiate(enemySlot, spawn1.transform.position, Quaternion.identity);
Debug.Log("spawn1 enemy created");
//yield WaitForSeconds(3);
}
else
{
Instantiate(enemySlot, spawn2.transform.position, Quaternion.identity);
Debug.Log("spawn2 enemy created");
}
}
I tried using the InvokeRepeating, but it still clone too many.
-
How do i add a timer or wait time to the code, so it will like every 3 sec then it will clone X enemies.
-
Where & how should i put my Xenemies in the code, so i can define like each Spawn execution, clone X number of enemies.
-
and how should I actually use the InvokeRepeating in this case to help my game?
Thanks in advance!