I got this - SendMessage Sliding has no receiver!

var Box : GameObject;
function OnMouseUp(){
this.SendMessage(“Sliding”);
Debug.Log(“1”);
Box.transform.Translate(Vector3(0,-3,0));
Debug.Log(“2”);
yield WaitForSeconds(1);
Box.transform.Translate(Vector3(0,3,0));
Debug.Log(“3”);
}
//////
(script2)

var second : Texture;
var third : Texture;

function Start () {
sliding = false;
MatLoop(0.1);
}
 
function MatLoop (speed : float) {
 if(sliding == false){
    while(true)
    {
       renderer.material.mainTexture = first;
 
       yield WaitForSeconds(speed);
 
       renderer.material.mainTexture = second;
 
       yield WaitForSeconds(speed);
    }
}
else{
renderer.material.mainTexture = third;
}
}

function Sliding(){
sliding = true;
while(sliding){
Debug.Log("Sliding ...");
}
yield WaitForSeconds(2);
sliding = false;

}

Ok , I’ve created these two scripts . One is meant to create the illusuion of running(Script2) , as in the textures changing all the time so it looks like your running . The other is so when you click a button the running animation stops turns into a third sliding texture . So when you click the button it’s ment to send a message to the second script function Sliding which makes it stop and activate the sliding and also make the gameobject go lower . But the message doesnt send and i get a - SendMessage Sliding has no reciever !.

This always happens to me with bloody SendMessage’s ! the “have no reciever” even though the functions there . Can someone explain how to fix it please ?

Thanks
Stealth

You shouldn’t really need the SendMessage if the two scripts are always together. You could just declare script2 as a variable and add it to script1 (assigning it in the inspector our using GetComponent) by doing:

var SecondScript : Script2;
function OnMouseUp()
{
	SecondScript.Sliding();
	Debug.Log("1");
	Box.transform.Translate(Vector3(0,-3,0));
	Debug.Log("2");
	yield WaitForSeconds(1);
	Box.transform.Translate(Vector3(0,3,0));
	Debug.Log("3");
}

SendMessages are pretty heavy to use as well, so this is probably a much lighter way of doing things.
Personally I prefer to use the GetComponent method and reference the script that way for future calls.

Edit:
The error may be due to your use of this (ie. this.SendMessage( "Sliding" ) ). Try using gameObject.SendMessage( "Sliding" ) instead. It might be trying to send to your Script instead of your object. You could also try putting a Sliding function in Script1 with a Debug to see if it is actually attempting to do this.