playMaker

Author Topic: Run FSM: How to get it to return variable data?  (Read 3918 times)

Red

  • Hero Member
  • *****
  • Posts: 563
Run FSM: How to get it to return variable data?
« on: July 31, 2014, 01:11:56 PM »
Hello again!

This time I'm wondering if there's a way to use the "Run FSM" action in such a way that it will calculate some stuff and pass that data back into the FSM that it's running from.

So, for instance, say I take that camera boundary testing thingamabob I talked about in another thread, embedded that functionality into a template and then used the "Run FSM" in a different FSM to tell it to run that... How, once it's finished performing the calculations required, pass the data back into the parent FSM that it's embedded in? So far all I can see are inputs... and no outputs... Is this simply not what it was designed for? If that's the case I can easily figure out a different way (or simply have it embedded in the FSM as a chain of events) but I would like to get my feet wet with this action on a more intimate level.

I guess in a pinch I could use the globals for this but I'd like to avoid doing that... Mainly because these are one-time use values and having a persistent global might be a bit of overkill.

... p.s. how does one export templates? is the process the same as with other exporting things and you just find the folder and select them in the exporting process or is there something deeper that I'd have to do in order for it to export/import properly?
« Last Edit: July 31, 2014, 01:22:19 PM by Red »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Run FSM: How to get it to return variable data?
« Reply #1 on: August 01, 2014, 06:42:41 AM »
Hi,

 no don't use globals here, it would be bad design.

 I'll ask Alex if there is a built in way, but typically, you should use "Send event" action, targeting "Host Fsm" and use "set event data" to pass all your values, this would be in place of using "Finish Fsm" action.

 Does that make sense?

Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Run FSM: How to get it to return variable data?
« Reply #2 on: August 01, 2014, 06:48:59 AM »
Hi,

 The other solution ( this is bothering me actually...) is to use "Set Fsm XXX" and target the owner, then you can set variables on your host. that worked I tested.

 Bye,

 Jean

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Run FSM: How to get it to return variable data?
« Reply #3 on: August 01, 2014, 03:58:24 PM »
OOh, nice!

Hadn't thought of that.

In the interests of modularity, though, how do these "nested" FSMs get treated? For example, what would I have to do to set up a routine in a "nested" FSM (one that's only ever used within an FSM with the "Run FSM" action) so that it will detect what it's "parent" is so that I can have, say, a couple different objects all using this template but each one having slightly different values that it needs to pass back?

For example, say in a multiplayer game you have the game instance running with the main player character and the instanced visiting player characters... Each character has the same general FSM that's controlling things like the position, rotation, etc... But in the case of the visiting player's gameObject it reaches in, grabs it's identity (as either a host or visiting controlled) and then determines what subset of nodes to run through?

I dunno... I know that this idea may not be the most ideal for this kind of situation... But communicating between parentFSM and childFSM is something that I think would surely help in being able to parse and understand so as to know how to address this kind of setup.

right now I'm thinking that the most ideal use I can think of right now would be using these FSMs to have controls for the camera system I'm working on... Since it has multiple modes and both horizontal and vertical being separate I'm wondering if it would shave down time, energy and CPU cost if I had each mode running an instance of the movement and having a way of detecting "This is the vertical controller" or "This is the horizontal controller." Since there are some minor differences between the two but the over-all modes behave nearly identically in how they do their thing.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Run FSM: How to get it to return variable data?
« Reply #4 on: August 06, 2014, 06:40:04 AM »
Hi,

 Sorry, I am not sure what the actual question is here :)

 Bye,

 Jean

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Run FSM: How to get it to return variable data?
« Reply #5 on: August 06, 2014, 10:02:50 AM »
Yeah, I know it's probably not the best example... :lol:

I guess what I kinda want to know is how the system handles it such that I can understand better when to use it and when to use different systems. If I can parse what it does on a more fundamental level I assume that'd help me to understand when it's appropriate to use it.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Run FSM: How to get it to return variable data?
« Reply #6 on: August 06, 2014, 11:08:20 AM »
Hi,

 Basically, there is not much here, you run a template within a fsm, that template becomes a sub fsm, and the fsm running this template becomes the "host".

 then, go wild!

Bye,

 Jean