Events and communication
pixelrevision
Member Posts: 1
Looking for the best way to communicate between objects. I want to make a controller that on touch tells another actor to do something. Is there a built in event/dispatch system, or a way to directly message another object by name? Trying to figure out the most optimal way to do this without checking a global on a timer.
Comments
If you want to share the global attributes with multiple instances of an actor, you can add another global attribute called "ActorID", "EnemyActorID", etc. Each actor would have an "ActorID" attribute itself that it could pass in to the global attribute along with its "message". The down side is if something (i.e. your player actor) interfaces with these multiple actors about the same time frame, you could have the multiple actors fighting for use of the global attributes (stomping over each others' "message"). This method would work if your multiple actors are distributed about the scene where the other (player) actor would only encounter one at a time (i.e. in a maze or where the multiple actors are stationary or separated enough through controlled movement paths). If you go this route, then the "ActorID" of each actor would either need to manually be set in each instance of the manually placed actor instance or if you spawned them, you would need an additional global attribute to keep track of the last ActorID used and increment it as they are spawned.