Hello, I’ve hit a bit of a wall with the game I’m making. I’m trying to add a grenade but my code doesn’t work. Unity just tells me"BroadcastMessage BombDamage has no receiver" and I can’t figure out the problem. Here’s the codes:
//This is on the bomb’s Explosion prefab after it’s been thrown and detonated
Bomb:
function Update () {
Die();
}
function Die () {
yield WaitForSeconds(2.0);
Destroy(gameObject);
}
function OnTriggerEnter(other: Collider) {
other.BroadcastMessage("BombDamage");
}
//And here’s the Important bit from the enemy’s script:
function BombDamage () {
health -= 100;
}
The BroadcastMessage should send to the enemy’s script through the explosion’s collider(which is just a retextured, animated sphere)
Help would be appreciated! Thanks!