- Home /
Question by
0V3RWR173D · Jun 30, 2010 at 12:03 AM ·
sendmessagebroadcastmessage
Broadcast Message Problems
When I try to broadcast a message to another object it has an error that says "BroadcastMessage theBroadcastedMessage has no receiver!"
I have a script for each object:
function OnCollisionEnter (collision : Collision) {
if(collision.transform.tag=="Bullet"){
//Do other things
BroadcastMessage ("PlayTheAnimation");
}
}
And for the receiving object:
function PlayTheAnimation () {
animation.Play();
}
I am not sure if I wrote the script with something wrong or its just an error from unity. I am not sure how to use BroadcastMessage because I only found a little about it in the scripting references. I would appreciate it if someone could give me some advise.
Comment
Best Answer
Answer by Mike 3 · Jun 30, 2010 at 12:14 AM
BroadcastMessage sends to the gameobject you're using it on, and all its children
In your case, it's doing it on the current gameobject
You'll need to get a reference to your other object and do yourOtherGameObject.BroadcastMessage