playMaker

Author Topic: Global Transition exclude self  (Read 1287 times)

puddlepouncer

  • Playmaker Newbie
  • *
  • Posts: 18
Global Transition exclude self
« on: June 15, 2020, 06:41:45 AM »
Hi, I have some feature requests regarding Global transistions. Unless I have missed a functionalty (fingers crossed  ;) )

I quite often run into scenarios where I want to avoid Global Transistions to catch an event and create endless loops. It would be great to have some kind of exclude self option to avoid this from happening. I have two scenario examples where this causes problems. (see attachment)

Scenario 1

I have multiple events that share many actions. To avoid many states with the same actions in them I'd like to save which is the current event (using last event action) and then just fork the state chain when needed using a string compare.
Unfortunatly the standard transition is picked up by the global transistion causing an endless loop.

Scenario 2

A global transition is picking up an event. It does some actions before it is passed along to other objects. Once again and endless loop is created. This can be avoided with broadcast event and "exclude self" option but it seems very costly (and not always wanted) to use broadcast event when not needed. Preferred  would be to have the "exclude self" in all send event types.


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Global Transition exclude self
« Reply #1 on: June 15, 2020, 08:09:52 AM »
Hi.
In Scenario 1 i can see that you use both Global and local.
It will always send 1st to the global which is the reason it does the infinite loop as it constantly goes back to that state.

if you use a global event you should not use the same event name for local.

In Scenario 2
Give the children a different event name (for example "Child/Event A)

Exclude self will only exclude a fsm, to have this on the other types would make no sense :)

Also you should use broadcast event only if you need to send a event a lot of objects/fsms

For the children i would make for example an array and place the children into that array (manual or with actions)
Then loop thru the array end send the event to each one.

Another way is have the children check the parent.
For example with a 'fsm bool test' (which you can set to true/false within your parent code.

Or use a "Fsm State Test"

How to do this is depending of your setup ofc.

puddlepouncer

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Global Transition exclude self
« Reply #2 on: June 15, 2020, 08:46:36 AM »
Thank you Djaydino.

I'm aware WHY this happens its just that I would like to have a way to avoid it hence the feature request :)

I have made workarounds using arrays, get next child, renaming events etc so its not a game stopper for me. Its just a little cumbersome. 

So in short. Ways of excluding global events to be triggered from within its own fsm is what i'm after. Which I suspect is often not a desired setup anyway. Broadcast Event has this option with "exclude self". My feature request is to have "exclude self" in other event triggering actions. It could be stated on the Global Transition to not be triggered from within FSM or from the event caster itself.     

See example image below for clarification 
« Last Edit: June 15, 2020, 09:13:34 AM by puddlepouncer »