- Home /
Question by
oinkoinkflapflap · Dec 23, 2011 at 06:25 PM ·
functionsendmessageelse
else for an entire function
i need an else for an entire function, like an else for an if statement but for a function, for example when the tag of "Player" is near i sendmessage to another object but when this function isn't being called i want it to do something else... thanks!
Comment
can't believe i didn't think of that, i was using more than just a sendmessage cus i was sending to all of the tag so i didn't notice :S cheers
Best Answer
Answer by jahroy · Dec 23, 2011 at 06:38 PM
function Update ()
{
if ( isPlayerNear() ) {
sendMessageToAnotherObject();
}
else {
doSomethingElse();
}
}
function isPlayerNear () : boolean
{
/* return true or false based on tags and positions */
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613062335im_/https://answers.unity.com/themes/thub/images/avi.jpg)