How do i Specify a Receiver for a Send Message Function?

Help! i am not looking to use: SendMessageOptions.DontRequireReceiver.

I have looked up on this in the script reference and the forums. I'm wondering how i would be able specifically give an game-object/script-function a reciever so the messages dosent relay anywhere else.

So far when i use: SendMessageOptions.RequireReceiver i get a dubug log saying e.g no receiver found, how can i get the sendmessage to get picked up by a component? whats the correct way to use SendMessageOptions.RequireReceiver. Thank you.


SendMessage is a way of broadcasting a message to "anyone that is listening". The option RequireReceiver just lets you know (via an error) if "no one was listening".

If you want to send the message to a specific recipient, you can just get a reference to it (e.g. via GetComponent) and call it. e.g. (C#):

Instead of:


You'd do:

MyScript myScript = GetComponent(typeof(MyScript)) as MyScript;

The JS version is very similar:

var myScript : MyScript= GetComponent(MyScript);


Thanks agen just saw this in the script reference, in any case others are intrested.