- Home /
SendMessage has no reciever
Hey all I am trying to send a message from one script to another along with a parameter but it gives me the error "SendMessage ShowMoves has no reciever" Here is the sender script:
void CheckPiece () { Ray PieceRay = new Ray (RaycastSource.transform.position, Vector3.up); RaycastHit Hit = new RaycastHit (); if (Physics.Raycast (PieceRay, out Hit, 4)) { CurrentPiece = Hit.collider.gameObject; } if ((CurrentPiece != null) && (CurrentPiece.tag.Contains ("Piece"))) { HasPiece = true; } else { HasPiece = false; }
if (GameObject.FindGameObjectWithTag ("SelectedPiece") == null) { gameObject.tag = "SelectedPiece"; } else { GameObject.FindGameObjectWithTag ("SelectedPiece").tag = "Untagged"; gameObject.tag = "SelectedPiece"; } print (GameObject.FindGameObjectWithTag ("SelectedPiece").name);
CurrentPiece.SendMessage ("ShowMoves");
}
Here is the reciever script :
void ShowMoves (string name) { print ("Message recieved"); DoubleMove = true; }
Any help please ?
The sender script is attached to 12 objects but only one of them functions correctly which is quite wierd