- Home /
receive message with if statement
Hi, I'm wondering how the code (in C#) would look like if I want to make an if statement, that responds to a message send by a different object. I guess I could figure this out if I knew how receivers work but the Documentation is a little short on that. Thank you very much!
Hmm, so I read somewhere, that sendmessage is extremely slow, so I will figure this out with GetComponent.
You are correct sendmessage is slow. If you want to do it though: Send$$anonymous$$essage("Your$$anonymous$$essage", (Optional)YourValue); And on the other object: void Your$$anonymous$$essage(){ //Do something. } IF you know the object's script you want to send it to, replace sendmessage with: TheScriptInstanceToSendTo.Your$$anonymous$$essage();
Your answer
Follow this Question
Related Questions
EnemyDmg not communicating to HealthDraw 2 Answers
About untity send messages with android? 0 Answers
Unity - AIfire Has No Reciver! 1 Answer
send message object variable 1 Answer
Receiving windows message in Unity 0 Answers