In my game, I’m trying to make a wave spawner, so that when every enemy dies it will start a new wave. Right now, either the death line or the variable itself is broken. Here’s my monster death system:
var Health : float = 100;
var MaxHealth : float = 100;
var Manager : GameObject;
function OnTriggerEnter(hit : Collider){
if (hit.CompareTag("EditorOnly")){
Health = Health - 1;
}
}
function Update(){
if (Health <= 0){
Manager.livingCreatures = Manager.livingCreatures - 1;
Destroy(gameObject);
}
}
And my Wave script (I modified it from an existing one):
var totalCreatures : int = 2;
static var livingCreatures : int = 0;
var waitToWave : float = 10;
var waveTime : float;
var yourCreature : Transform;
var CurrentWave : float = 1;
var text : GUIText;
function Update() {
text.text = CurrentWave.ToString();
if (livingCreatures == 0) {
if (waitToWave <= waveTime) {
waveTime = 0;
livesCreatures = totalCreatures;
for (var i = 0; i > totalCreatures; i++)
Instantiate (yourCreature, Vector3(0,0,0), Quaternion.identity);
totalCreatures = totalCreatures * 2;
CurrentWave = CurrentWave + 1;
}else {
waveTime += Time.DeltaTime;
}
}
}
It’s getting an error that says “NullReferenceEception: Object reference not set to an instance of an object.”
Please help!