Id like something to happen, once all robots and sentry guns are wasted in th fps tutorial. Specifically, Id like to load a specific level, or even enable a gui. So how would I go about recognising that all enemies are detroyed?
function Update(){
if (all robots and sentryguns are destroyed(robots and sentryguns));
Application.Loadlevel("You Won");
}
Obviously this wont work, but you get the idea
Totally digging the new release guys
AC
One way would be to have a static variable somewhere with the total number of enemies, and each time one is destroyed, subtract one from the number. When it’s 0, there you go.
Apart from indentation, both versions look identical.
In both versions the list of enemies is only fetched at game start. You will need to refresh the list inside the Update function:
function Update(){
var enemies = GameObject.FindGameObjectsWithTag("myTag");
if (enemies.Length <= 0)
{
Application.LoadLevel ("YouWon");
}
}
Ok now its compiling…
Thanks team-I havent really done anything where the varibiles are inside the Update function, only outside. I’ll give this a go, it should work now
Thanks
AC