- Home /
SendMessage to all gameObject children
Hi!
There is a SendMessageUpwards function, which sends message to all gameObjects in upper heirarchy, but i wonder is there SendMessageDownwards? It seems that there is none.
I just need to Send a message to all gameObject children not requiring receiver...
Also what is the difference between BroadcastMessage and SendMessage?
Thanks in advance!
I too would like a Send$$anonymous$$essageDownwards or Send$$anonymous$$essageToChilren function.
I'm afraid to use Broadcast because if it sends the message back to its self it will likely cause an infinite loop for what I'm trying to do. I can kludge it or work around it in many different ways, but if someone knows a simple efficient way of doing it I would be grateful to whoever could share it.
Answer by Eric5h5 · Aug 19, 2011 at 06:57 PM
The docs clearly explain what the difference is; e.g. for BroadcastMessage: "Calls the method named methodName on every MonoBehaviour in this game object or any of its children." As opposed to SendMessage: "Calls the method named methodName on every MonoBehaviour in this game object." So that should answer the first question.
Answer by ematsuno · May 07, 2018 at 10:10 PM
@G_Sacristan: to clarify the answer: use BroadcastMessage. It will send the message to all contained objects.
SendMessage does not traverse the hierarchy
Your answer
Follow this Question
Related Questions
Send message to other objects in list 0 Answers
Child object collision 2 Answers
Help With Homing Missiles - Annoying! 3 Answers
how to make one script change a variable in another scipt 2 Answers