Is there a way to send a message to all other objects currently instantiated?
I know the existence of GameObject.SendMessage but as I understand it is limited to scripts within the same object.
My scenario is the following :
I have a GameLogicObject and multiple BadGuyObject(s). When my hero kills a BadGuyObject, I want to emit a message to all objects and anyone can subscribe to a BadGuyKilled message.
I would want to write something like that :
//From BadGuyObject
transform.SendMessage ("BadGuyKilled", transform);
//From GameLogicObject
function HandleBadGuyKilled (badGuy:Transform) {
score += 1;
}
Right now, I have a reference to the GameLogicObject from the BadGuyObject and I call directly the HandleBadGuyKilled method but my goal is to eliminate the dependency.