playMaker

Author Topic: Run FSM action question  (Read 4851 times)

vamky

  • Playmaker Newbie
  • *
  • Posts: 16
Run FSM action question
« on: January 19, 2016, 10:05:52 AM »
Hi:

I am messing around the run fsm action and somehow my idea did not work:

I created a fsm template with a float variable [Time] and a string variable [Event], and a master fsm to run this template with run fsm action.

My intent is to use a master FSM to run multiple instance of a same fsm template with different input, so the sub fsms would return different event at different time waited.

The result is that the master FSM can only receive one returned event, Am I doing anything wrong?

Cheers
Kenyon
« Last Edit: January 19, 2016, 10:13:14 AM by vamky »

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Run FSM action question
« Reply #1 on: January 19, 2016, 07:27:48 PM »
From your first image- if you want the send event to work after the wait time- then put the wait action and send event on different states- then use the wait actions "finish event" to go to the state with the send event on it- right now the wait action isn't doing anything-
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

vamky

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Run FSM action question
« Reply #2 on: January 19, 2016, 08:08:53 PM »
Hi mdotstrange:

you do not have to put wait and the other action on different state if you make that state a action sequence. You can try it yourself, there is nothing wrong with the wait->send event, the master FSM in my setup can receive the first returned event, but not the second and third.

Cheers
kenyon
 

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Run FSM action question
« Reply #3 on: January 19, 2016, 08:49:41 PM »
A wait state with no finish event will just wait its time and try to use a Finished transition but there isn't one on the state so it doesn't really do anything- it won't delay the action underneath it- they will run at the same time-

Try manually entering 10 seconds in the wait time- it will still fire the send event at the same time that it runs the wait action.

If you want to delay the send event by a time it has to be on a different state than the wait action-

Here's a video explaining how to use the wait action https://www.youtube.com/watch?v=C8qg2wpRA9Q
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
Re: Run FSM action question
« Reply #4 on: January 19, 2016, 08:51:34 PM »
A wait action will stop the FSM proceeding to the next state until it's timer is finished  but any actions taking place in the same state will continue as normal.

vamky

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Run FSM action question
« Reply #5 on: January 19, 2016, 09:27:09 PM »
Hi

Please guys, try it yourself before saying what is wrong, use the state as an action sequence.

Right click in the action editor, check the "action sequence" in the menu. As you can see in the attached img.

Cheers
Kenyon
« Last Edit: January 19, 2016, 09:41:56 PM by vamky »

Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
Re: Run FSM action question
« Reply #6 on: January 19, 2016, 10:21:41 PM »
Okay, I had a little play around with it, and from my understanding (Which is minimal - i've never used templates) When you use a RunFSM Action, it runs that FSM to completion (for example, until it reaches a "Finish FSM" Action) before moving onto the next task, But, as your first template sends it to another Event, it never gives the inputs to the other templates.

Edit: Additionally, When the host is sent to another event, it disables the template FSM that was running. I don't think it's possible to have multiple copies of the same template accessed by the same host at the same time.

I discovered this trying a workaround, whereby an extra input string was used to send the host to an event starting the next template (So Template 1 would send the host to an event beginning Template 2) before doing it's wait action. Only the final template ran through to completion.
« Last Edit: January 19, 2016, 10:59:21 PM by Chizzler »

vamky

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Run FSM action question
« Reply #7 on: January 20, 2016, 12:36:16 AM »
Hi Chizzler:

Thank you for your information. Like you said, Run FSM cannot run multiple template fsm at the same time, which is a shame. I can work around this by create a prefab game object which contains a fsm I want to reuse, them use create game object action (or spawn from pool) to create multiple instance of that prefab in run time, then run each fsm with its own variable setting. But while this works, the process is nowhere user friendly as Run FSM action in which you can just type inputs in one simple action.

I guess its time to ask our programmer for help.

Thanks again!
Kenyon

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Run FSM action question
« Reply #8 on: January 20, 2016, 01:25:31 AM »
Hey sorry, you are correct- I missed the "action sequence" part  :)

I recently had some problems with Run Fsm in Playmaker 1.7.x - I upgraded to 1.8 and the problems went away- moving to 1.8 might help if you aren't already using that version.

Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Run FSM action question
« Reply #9 on: January 20, 2016, 07:18:18 AM »
The initial Start State is indeed running all 3 instances of that Sub FSM but it appears that when the Host FSM exits that state then the Run FSM ends itself. This might be to avoid uncollected garbage from loosely designed systems.

I don't really see a way around that, since even if you nest the FSM's it will still be dependent upon the uppermost parent FSM remaining in its state which is contrary to your design goal. Alex would probably need to expose an optional flag that would allow the SubFSM to survive when the Host changes states.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

vamky

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Run FSM action question
« Reply #10 on: January 21, 2016, 04:21:47 AM »
The initial Start State is indeed running all 3 instances of that Sub FSM but it appears that when the Host FSM exits that state then the Run FSM ends itself. This might be to avoid uncollected garbage from loosely designed systems.

I don't really see a way around that, since even if you nest the FSM's it will still be dependent upon the uppermost parent FSM remaining in its state which is contrary to your design goal. Alex would probably need to expose an optional flag that would allow the SubFSM to survive when the Host changes states.

That optional flag in the future would be super awesome! ;D ;D ;D