playMaker

Author Topic: Handling multiple FSM  (Read 1378 times)

V01D

  • Playmaker Newbie
  • *
  • Posts: 2
Handling multiple FSM
« on: April 19, 2018, 10:21:55 AM »
Greetings everyone,

I had a problem while developing with Playmaker, I divided my FSM into basic movements, Attack states and Hit State for organizing. However, the attack state can override the basic movement state (walking as an example). My approach was to mimic MUGEN's organizing way(divide and conquer).

Everything was working fine before I divided them into multiple FSM states. Transition from Idle to attack will prevent movement all together. Now, I can solve that easily with boolean, but I want to know what is the best practice for such problem and is there a way that I can force Playmaker to run one and only one state regardless how many FSM are there?

I also noticed that global event such as OnTriggerEnter2D was working even if the other same game object didn't get hit by trigger box2D. So, does that mean the global events will run not on instance-based, but class-based? What if I want to make local multiplier, how can I solve that, do I have to make copy of FSM?

Regards,

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Handling multiple FSM
« Reply #1 on: April 19, 2018, 02:39:32 PM »
Hi.
If you have movements on the attack fsm, you should transfer them to the movement fsm.

Then make a (global) event/transition (on the movement fsm) to activate that attack movement.

Then on the attack fsm you can use a "Send event by name", target the movement fsm and place the name that you called the event/transition for the attack movement. (you can also use send event, but then you need to make the event globlal. I prefer to minimize using globals)

for the OnTriggerEnter2D can you show the fsm/states/actions from the fsms that uses this.

Or you can pm me a link to your project and i can have a look.

V01D

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Handling multiple FSM
« Reply #2 on: April 20, 2018, 05:47:47 AM »
Quote
If you have movements on the attack fsm, you should transfer them to the movement fsm.

The current structure is the following:-

FSM: Basic movements
- Idle
- Walk Right
- Walk Left
FSM: Hit States
- HitState
- Recovery
FSM: Attacks states
- Attack

Quote
Then make a (global) event/transition (on the movement fsm) to activate that attack movement.

Then on the attack fsm you can use a "Send event by name", target the movement fsm and place the name that you called the event/transition for the attack movement. (you can also use send event, but then you need to make the event globlal. I prefer to minimize using globals)

Well, that will be a good solution, but I think I will need to add the action in all 3 movement states, right? 

Quote
for the OnTriggerEnter2D can you show the fsm/states/actions from the fsms that uses this.

Or you can pm me a link to your project and i can have a look.

I will PM you the project, it's actually a test lab of sort using placeholders.
Thanks for taking the time to help me.

Regards,