Hi,
OK, so my level has 16 cubes on a grid. If you touch one cube, I detect all bordering cubes and send an even to them to play an animation.
At the moment, I'm doing this via;
A cube has a child object that just contains a trigger zone collider.
I have 15 FSMs on this trigger zone object, one for each other cube on the map
These start with a global event (not a start event), e.g. "Cube 1 Clicked", and then use Trigger Event "On Trigger Stay", if it matches another cubes tag, then it progresses to another state where it then sends an event to that corresponding cube.
This works fine, it detects the right cubes and the timings are perfect.
However, I noticed when duplicating these FSMs to test out a secondary design idea, that performane was severely hit. I guess 15x16 FSMs is the problem, coupled with the fact that when Cube1 is clicked, it activates 15 FSMs and the ones that aren't matched just sit on the "On Trigger Stay" event waiting for a match. This is probably quite inefficent?
So what are my options?
Should I add a small wait step so that if another cube doesn't match, then it goes back to the nothing Start state (and isn't therefore on an "On Trigger Stay" event)?
Or should I look at raycasting from my clicked cube in 4 directions (at a specific length) to find bordering cubes?
I couldn't see an easy way of detecting what 4 cubes (in particular states) were nearby and bordering my original cube.
This might explain the performance problems I encountered on Android, which didn't get resolved even after changing shaders and vfx to cheaper elements.
Thanks in advance.