Hello everyone!
We are using playmaker to try and build what essentially amounts to a level editor for a project we're working on. That is, we want to have simple behaviors encapsulated in actions like playmaker already does so well, but we also want to have larger, complex behaviors that are composed of actions encapsulated in some way as well. The idea is to be able to string together these complex behaviors to give ourselves even bigger building blocks than actions.
A couple examples of complex behaviors might be:
-Make this object drag-and-droppable and wait for it to be dragged to a target, firing onHover and onDrop events as necessary.
-Explode this game object by adding colliders, an explosive force, a selected particle effect, etc.
-Ask for keyboard input from the user by bringing up a UI and store that input in some specified variable.
Now, we're not sure exactly the best way to go about this but we had some ideas, and I'm curious to see what other playmaker users have done or what they would do. Some of our ideas are as follows:
1. We've thought about using templates to encapsulate complex behavior, in which case the current runFSM and Foreach actions feel a little limiting (specifically for running behavior on multiple targets simultaneously and providing input to the templates). But this might be the best solution if we were able to create custom actions to run FSM templates.
2. We've thought about just making large, complex actions, or maybe just scripting singleton objects that hold behavior that's simply manipulated by playmaker actions. This solution has the problem of bloating the code-base and being less flexible and reusable.
3. We've thought about just using FSMs prefabs that we instantiate which take input and provide output. This is like solution 1, but without the limitations of templates, losing some benefits of ease of use and creating a problem where multiple instantiations of gameobjects that hold FSMs are required for many objects running the same behavior (say 50 targets all exploding at once).
Anyway, all of our potential solutions seem to have a common problem that needs solving, namely: What is the best way to communicate between FSMs? The built in way seems to be to use event data and events for communication and data delivery, but is this truly the best method of communication between FSMs? Does anyone have a project where they've done it better? The problems with event data for us is that
(1) it's not transparent to one FSM what data another FSM requires to be bundled with an event. We have an action we are working on that does some playmaker-style reflection to try and make that clearer, but it's messy right now. (2) Only one data-object of each FSM type can be sent at once. We build our own send event info action to overcome this limitation, but it's a little clunky, packaging a custom data object and sending it through the FSM Object event data slot. (3) Bloating the global event namespace with a thousand different event names and requiring senders to have prior knowledge about what events another FSM responds to. We might be able to overcome this somewhere through a strong naming convention, but that's a little bit of a band-aid.
Sorry for the longish post, but here's my curiosity: Has anyone else wrestled with the kinds of problems that we currently are? (How to use actions to compose larger, most complex yet reusable behaviors, and creating robust inter-FSM communication.) And if so, what solutions did you end up coming up with? Or, is there some resource out there that has suggestions on this kind of thing?
Thanks a lot guys! And happy playmaking.