hi, in my game i want to spawn ships at random intervals up to a maximum amount. i started the script off but got stuck along the way if you could please help.
i have commented the parts that i need to do and given a short description of what to do. First, make the script wait for a random number of seconds using the min and max auto spawn times. Secondly, complete the if statement by finding the number of ships that are a child of the ShipController and whether there are less than the maximum ships allowed. If the number of ships is less than the maximum allowed then the script will spawn another ship, else it will stop autospawning by setting ‘autoSpawn’ to false, ending the while statement.
var maxShips:int = 4;
// min and max time between automatically spawning ships
var minAutoSpawnTime:int = 10;
var maxAutoSpawnTime:int = 30;
function StartAutomaticSpawn()
{
// autospawn toggle
var autoSpawn:boolean = true;
// while allowed to autospawn
while (autoSpawn)
{
// wait for a random X seconds (between min max) //NEED HELP
// if there are currently less ships than the max allowed
if ( ) //NEED HELP
{
// spawn another ship
SpawnShip();
}
else // otherwise stop autospawning
{
autoSpawn = false;
}
}
}