x


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.

more ▼

asked Jun 30 '10 at 12:03 AM

0V3RWR173D gravatar image

0V3RWR173D
190 10 11 25

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Jun 30 '10 at 12:14 AM

Mike 3 gravatar image

Mike 3
30.5k 10 65 253

Thanks, that really helped.

Jun 30 '10 at 12:27 AM 0V3RWR173D
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x184
x31

asked: Jun 30 '10 at 12:03 AM

Seen: 3036 times

Last Updated: Jun 30 '10 at 12:17 AM