Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: FritsLyn on July 07, 2013, 01:12:36 AM

Title: "Return from subroutine" - use something and go back?
Post by: FritsLyn on July 07, 2013, 01:12:36 AM
Let's say that in many places in my game I need to flip a Global Bool, and when that is done, maybe add a little to a few other global variables, but at development time I'd like to experiment with that.

It would then be nice to just make 1 "Sub routine" (like in an empty Game Object) where this is done, and then being able to call this from various places in other independent states/events.

I do not believe this is not possible, but I cannot figure out how :) ?

Action: "Go To Previous state" is not doing the trick.

Thanks for any hints :)
Title: Re: "Return from subroutine" - use something and go back?
Post by: jeanfabre on July 09, 2013, 02:12:27 AM
Hi,

 Do you mean during editing? that's not possible, Playmaker only runs its FSM during runtime.

if you only need to set global var, that's perfectly possible.

1: have one gameObject with on fsm "manager".
2: implement a global event "SET SOMETHING" or something
3: fill in event data if you need to pass more values with it
4: from the various places, instead of setting that global var, fire this event with the value you want to store,
5: this Fsm "manager" will receive that global event, extract the value you passed, and set that global variable himself.

then you have your reusable "behavior" that you can call from anywhere.

 this is VERY good practice to build such systems, simply because if you perform the same thing in different places, it make sense to refactor and have one entity responsible for it, easier to debug, easier to maintain, and easier to further develop.

bye,

 Jean