playMaker

Author Topic: Any notion of global state/actions?  (Read 1509 times)

Grofit

  • Junior Playmaker
  • **
  • Posts: 73
Any notion of global state/actions?
« on: January 19, 2014, 04:44:01 AM »
I have a situation where the entity with the FSM applied can do a manner of different things, however I need to check in almost each one of these states to see if an attack button has been pressed. As when one of the attack buttons is pressed it would trigger a global transition into the attacking triggers.

As this is a lot of duplication I was wondering if there was a better way to model this. I did think about making the events and variables used global and have another FSM in the scene which would trigger it (like a input manager) however I could forsee a problem if I was in a state where I should not be able to break out into an attack (for example being dead or knocked down).

The previous comment also implies that this is not a true global state as there are some exception to when you would want to break out from the current states, however it seems like a common thing so just wanted to see how other people solve this problem?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Any notion of global state/actions?
« Reply #1 on: January 21, 2014, 07:29:37 AM »
Hi,

It really depends on what these states are actually doing, I am not sure I can provide helpful comments without knowing more. Typically tho, when I fyce this it's because I haven't defined and cut down the feature in several Fsm, and that is usually the best way to approach this.

typically, the question raised here is the following: If in state A you know that atttack button if on, why move to state B if when attack is on state B should not perform anything as well... there is a flow int he logic here, if a series of states ( linked by transitions) each performs the same initial checks, then you should only do it once at the beginning of the chain and have a global event in that fsm that can exit that series gracefully, since you can only have one active state at a time, it solves the problem. you are left with the need of a second fsm that constantly check where or not to fire that global event.

I hope it make sense.

bye,

 Jean

Bye,

 Jean