playMaker

Author Topic: Playmaker as high level tool for bulding finite state machines?[SOLVED]  (Read 2267 times)

Eldir

  • Playmaker Newbie
  • *
  • Posts: 2
Hi there.

First I apologize if this is not the proper place for this question but I didn't found any better.

Let me start putting some context to the question. I'm a kind of experienced Unity developer and I find the state-driven pattern as a very useful approach in very different ways. So far the best way I've found for working with it is implementing each state for a given entity in a different class with Enter/Update/Exit methods and then instantiating such states from the owner entity and put them in a kind of pool/dictionary/whatever to handle them.

In a nutshell, is working amazingly well but still with some flaws, in particular if the machine is relatively complex (lots of states and/or lots of transitions) it can be difficult to understand how the manchine works.

I recently read somewhere an article (or maybe was a youtube video) where someone recommended using 'coding for the states and then visual tools like Playmaker for the state machine and transitions' and since them I'm thinking of giving Playmaker a try but I would like to know if it's something really useful for doing this before buying the asset.

Could any of you please tell me if it really would be worthwhile for this task and give me a glimpse of how the implementation of the machine could be address?


Thanks!!
« Last Edit: March 13, 2020, 02:19:03 AM by jeanfabre »
La Garde mort mais ne se rend pas

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Playmaker as high level tool for bulding finite state machines?
« Reply #1 on: March 05, 2020, 02:16:53 PM »
Hi,

I don’t exactly understand the question, but here’s an approach. You can watch a few YouTube videos to get an idea how it works.

In a nutshell: you can code your own scripts (called an action) to place it within a state, and Playmaker gives you the visual logic to move in and out of that state based on whatever logic you want. It works with minimal adjustment when you know how to code. I.e. you can write your own in c# easily and turn those scripts on and off based on conditions, making most use of state based logic.

However, most users probably cannot code and here Playmaker provides a giant library of “microscripts”, said actions, that can do most tasks (setting velocity, passing triggers to the animator and so on), including elaborate conditions to determine into which state to move based on what.

That means, you can easily put together a state’s behaviour using those actions, determine the rules and conditions to go to other states, and finally, if you can code, write your own modular actions and endlessly combine them.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Playmaker as high level tool for bulding finite state machines?
« Reply #2 on: March 06, 2020, 01:11:33 AM »
Hi.
1 big advantage that playmaker has is that its not mirroring (except for a few states that are there to use if you can't find certain actions, mostly for 3rd party asset like 'Get/Set properties' actions)
which means its faster that other state machines that use mirroring.

Another one is that you can write your own actions and go quite complex with it

Here is a link to the Playmakers API Reference

The downside for non coders is that not all 3rd party asset have actions/support for playmaker.
But Get/Set properties can still help there, and many people also make custom actions which can be found on the Ecosystem

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Playmaker as high level tool for bulding finite state machines?
« Reply #3 on: March 06, 2020, 03:47:26 AM »
Hi,

 The complexity of a state machine would be just as daunting and even more cumbersome without playmaker, regardless of your framework. Complex OOP or complex MVC are just as messy after a while and as your project grows in size...

Documentation and strict conventions are key here to keep your project sane regardless of the tech you are using.

Yes, it's a very good idea to use PlayMaker as a backbone for your logic and have the rest coded in a regular way.

since you are a coder already, make sure you create the proper set of custom actions to go with your scripts, don't use the Get/Set Properties or invoke actions as they are affecting performances and are only there for non coders to be able to achieve their logic without coding.

I suggest you first try to understand playmaker on its own before mixing it up straight away with your own scripts. make sure you fully grasp the few rules about what a PlayMaker FSM is, where the power lies and where the restrictions applies ( typically, you can have only one active state per fsm, that's something to take into account straight away in your design patterns).

Usually, you will end up with a series of custom actions to communicate with your scripts and inform about state entering, and exiting. your script will then be told to start and stop execution by these actions. Try to come up with a convention and likely a c# interface so that you only build these actions that can accept any of your scripts.

you could have only one action per state, that has a field for a gameobject, and on that gameobject, the action will search for a component with the specifiied interface and will communicate via that interface to tell the script to start and stop executing. your script should also be made aware of that action script so that it can possibly tell the action that the execution is done. Or your script could fire a playmaker global event, which would be ideal, because more fsm can react to that script activity.


Bye,

 Jean


Eldir

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Playmaker as high level tool for bulding finite state machines?
« Reply #4 on: March 07, 2020, 05:30:30 AM »
Thanks folks!

You were very helpful. After reading you and some further research it seems to me that I can make good use of this so I'm going to buy it and give it a try.. .so you will see me around here in the future.

Again, thanks for the help!
La Garde mort mais ne se rend pas