I have an FSM (let's call it A) attached to an "Is Trigger" Box Collider, which uses the "Trigger Event" Action to detect a collision and notify another FSM (let's call it B).
This setup worked perfectly when A only detects one collision, but when it detects multiple simultaneous collisions I hit a problem. That's because FSM B has to wait for an animation to complete before it can complete the processing of the collision, and while it's waiting for the animation it receives additional events from FSM A for the other simultaneous collisions, stopping FSM B from completing processing of the first collision.
If I remove the animation wait in FSM B then everything behaves as expected, in other words FSM B has time to complete all other processing before FSM A sends the next collision event. However, I need this animation wait for the game to behave properly.
My first attempt at a solution was to add a wait to FSM A, so that it would only send a collision notification to FSM B after FSM B had replied that it had finished processing the first collision. This didn't work because while FSM A was waiting for FSM B it wasn't sitting in the "Trigger Event" Action and missed the other collisions.
My current solution is to completely de-couple FSM B from events sent by FSM A, by adding a new FSM (C) that listens to FSM A's collision events, but just adds the detected collision to an ArrayList. Then I re-structured FSM B to start with a check-wait on the ArrayList contents, only handling a collision when it finds an item in the ArrayList.
This current solution is working, but it doesn't seem very efficient to be polling an ArrayList once every one-hundredth of a second, just to de-couple FSM A and FSM B. Is there a better approach to handling multiple simultaneous Trigger Events in PlayMaker?