Assuming there are 4 tanks placed in the Tanks tutorial scene, how can you toggle between 1 to 4 players with an options button? Would the buttons enable and disable the tanks based on number of players selected? Or can you change the arrays length to limit the maximum number of tanks that spawn? Or maybe the button would just set a public integer value and say for (int i = 0; i < [integer value specified by button]; i++)?
Hello. Try making your code a bit more dynamic.
In cases like your, avoid using Arrays and use Lists.
So for example we should have that kind of code :
List<TanksObject> listOfTanks = new List<TanksObject>();
So when you want to add a tank in the list you would do :
listOfTanks.add(aNewTank);
and you would do a loop like this :
foreach(TanksObject tank in listOfTanks)
{
// Loops through all tanks added in the list
}
Lowering the players count would be easy. All you have to do is :
listOfTanks.remove(tankToRemove);
I hope this helps. If you still have problems, please post a snippet of code so we can further help you.