- Home /
SendMessage script problem
My sendMessage script is causing problems. Here is the code;
//Code-Line on one object
GameObject.Find("Game").SendMessage("count");
//And on the other (recieving) object called Game.
function count () {
ballsHit++;
if (ballsHit >= requiredBalls){
print ("You win");
}
What exactly is the problem? Is it that the function isn't being called, or maybe an error is being printed? Do you have multiple objects named "Game"? Why not just call the "count" function directly ins$$anonymous$$d of using Send$$anonymous$$essage?
Answer by macdude2 · Jun 04, 2011 at 09:50 PM
I am not sure if you need to do sendmessage("count", null) or if you are allowed to leave null out. And it looks like you are missing a parenthesis on function count()
Answer by Twayne · Jun 05, 2011 at 01:15 PM
You need 1 more } at the end. Otherwise it looks right to me unless the variables scope.
I noticed that, just missed it out. I was copying and pasting, and there is more stuff afterwards. Also, the console would have given it away.