- Home /
Question by
ina · Jul 25, 2011 at 07:24 PM ·
gameobjectmessagebroadcastmessagebroadcast
Send messages to different gameobjects
Is it possible for gameobject A to broadcast to many other gameobjects that are not its children?
Comment
Answer by Alec-Slayden · Jul 25, 2011 at 07:32 PM
SendMessageUpwards will work for ancestors, which (if shared) can broadcast the message.
You could also tag them, and do a FindGameObjectsWithTag into a GameObject[] array, then cycle through them in a loop using GetComponent to access the scripts directly. This may be more efficient.
[4]: http://unity3d.com/support/documentation/ScriptReference/Component.SendMessageUpwards.html
[5]: http://unity3d.com/support/documentation/ScriptReference/GameObject.GetComponent.html
I guess group all objects in a main empty game object node, and Send$$anonymous$$essageUpwards to broadcast to all ancestors