Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: vamky on January 19, 2016, 10:05:52 AM

Title: Run FSM action question
Post by: vamky 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
Title: Re: Run FSM action question
Post by: mdotstrange 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-
Title: Re: Run FSM action question
Post by: vamky 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
 
Title: Re: Run FSM action question
Post by: mdotstrange 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 (https://www.youtube.com/watch?v=C8qg2wpRA9Q)
Title: Re: Run FSM action question
Post by: Chizzler 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.
Title: Re: Run FSM action question
Post by: vamky 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
Title: Re: Run FSM action question
Post by: Chizzler 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.
Title: Re: Run FSM action question
Post by: vamky 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
Title: Re: Run FSM action question
Post by: mdotstrange 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.

Title: Re: Run FSM action question
Post by: Lane 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.
Title: Re: Run FSM action question
Post by: vamky 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