Waiting for an entity to appear/attach. Events? Coroutines?
Options
chr
✭
in Photon Bolt
In many of my scripts -- both on entities and normal MonoBehaviours -- I wait for specific entities to appear. My current solution is a mix of coroutines that search a few times every second, and events that I trigger when an entity has been attached. Neither works well.
Is there a better way? What do you do?
Is there a better way? What do you do?
0
Comments
-
public override void Attached() {}0
-
hmm..
Im not exactly sure if there is a better way but maybe some kinda coroutine
on your plate.
while(table.isReady == false) { yield return new WaitForSeconds(0.1f); }
then inside of your table.
public override Attached() { isReady = true; }0 -
Yup, that's close to what I'm doing at the moment. It works, but it's not very clean. Using events can in some cases make it more simple (when an entity has attached it triggers an event for anyone listening)0