The game runs, but every time an enemy spawns, I get one of these errors on line 32, or the second “if” statement in the OnTriggerEnter function. The Sniper Rifle bullets don’t register hitting the enemy, and I think this error has something to do with it. I have no idea why I get this error though.
var health : float = 100.00;
var SpawnPoint : Transform;
var Blood : Rigidbody;
var Dead : Rigidbody;
var Bullet : GameObject;
var SniperBullet : GameObject;
function Update() {
Bullet = GameObject.Find("Bullet 1(Clone)");
SniperBullet = GameObject.Find("Bullet 2(Clone)");
if(health <= 0.0)
Death();
}
function Death() {
var Boom : Rigidbody;
Boom = Instantiate(Dead, SpawnPoint.position, SpawnPoint.rotation);
Destroy(gameObject);
Points.Score += 10;
}
function OnTriggerEnter(other: Collider) {
var Spawn : Rigidbody;
if(other.gameObject.tag == "Bullet")
{
health -= 25.0;
Points.Score += 5;
Spawn = Instantiate(Blood, SpawnPoint.position, SpawnPoint.rotation);
Destroy(Bullet);
}
if(other.gamObject.tag == "SniperBullet")
{
health -= 100.0;
Points.Score += 5;
Spawn = Instantiate(Blood, SpawnPoint.position, SpawnPoint.rotation);
}
}