Ok, so below is the script that is giving me trouble. I’m pretty sure i’ve followed the instructions given on the “Instantiate” reference, but i keep getting a “NullReferenceException: Object reference not set to an instance of an object” error, on the line where i give the Instantiate instruction.
What object do i need to instantiate? is it not properly instantiated?
Thanks ahead for any help, it will come in very valuable.
public var maxHealth = 100;
var currentHealth = maxHealth;
public var explosionObj : GameObject;
function Start(){
}
public function Damage (dmg : int){
currentHealth = currentHealth - dmg;
if (currentHealth == 100){
}
if (currentHealth >= 75 && currentHealth < 99){
}
if (currentHealth >= 50 && currentHealth < 74){
}
if (currentHealth >= 25 && currentHealth < 49){
}
if (currentHealth > 0 && currentHealth < 24){
}
if (currentHealth < 0){
if (gameObject.name == "Player_0")
Application.LoadLevel("teste leve");
else{
Debug.Log("i should be dead");
var explosion : GameObject = Instantiate(explosionObj, gameObject.position, gameObject.rotation);
Destroy(gameObject);
}
}
}