SendMessage dont work.

I’m trying to do a very simple game, but I have a problem with SendMessage. To test the mistake I made up a new project and created two objects, one with each script:


function Start () {



function a (b : int) {
GetComponent.().material.color =;

But when I start nothing happens and appears the error message, the SendMessage has no receiver!

I do not know what to do.

As documentation states

Calls the method named methodName on
every MonoBehaviour in this game

So if you want to send message to other object you need a reference to its GameObject.

You can do via multiple ways but the best is to define it as public variable

public GameObject receiver. 

And drag it in the inspector. than in the code you just do


but if you know what the receiver will be, the even best way is to store the reference to the class and call the method directly since SendMessage might be expensive if you have many components on gameObject.

This btw would be for C# since i dont know Java :slight_smile: but should be similar