I want to make an enemy prefab which would send a message to player when gets destroyed. The problem is that I cannot assign objects from scene to prefab slots in Inspector. FindWithTag function is not working either...
public var lives = 25;
public var blood : GameObject;
var t : MonoBehaviour; //Target of the message to be sent
var message : String ; //Message to be sent
function Start(){
var t = GameObject.FindWithTag("PlayerTag");
}
function Update (){
if(lives <=0){
dead = true;
Destroy(gameObject);
Instantiate (blood, transform.position, transform.rotation);
t.Invoke(message, 0);
// iTweenEvent.GetEvent(GameObject.FindWithTag("PlayerTag"), "Shake").Play();
}
}
function OnTriggerEnter ( other : Collider){
if (other. tag == "bullet"){
lives -=1;
Destroy( other . gameObject);
}
}