- Home /
Load the next level once all enemy's are died...
I apologise for all these load level questions but could some one give me a script so when all of the robots from fps tut are died it loads the next level??
Thanks!!
Answer by Berenger · Dec 28, 2010 at 11:25 AM
I don't know that tut, but the easiest way would be to have a static variable, like nbLeft, that decrease when an enemy die, and when nbLeft == 0, Application.LoadLevel("[level name]"); Something like that (put that script on an empty GameObject, and whenever an enemy die, call [script below name].OnEnemyDeath()) :
var nbLeft = 10;
static function OnEnemyDeath() { if( --nbLeft <= 0 ) Application.LoadLevel("[level name]"); }
so does the script go onto the enemy or player? do i change "var nbLeft = 10;" to "var nbLeft = 2;" if i have 2 enemies?
(5,8): BCE0050: Operator '--' cannot be used with an expression of type 'error'.
(5,10): BCE0020: An instance of type 'loadlevel0cars' is required to access non static member 'nbLeft'.
this is the errors
Your answer
Follow this Question
Related Questions
Adding a load level to this script. 1 Answer
Why is this script causing a lot of lag? 2 Answers
need help with AI 3 Answers
Movement around a huge object by avoiding obstacles 1 Answer