Playmaker Forum
PlayMaker Help & Tips => PlayMaker Tips & Tricks => Topic started by: qholmes on February 05, 2012, 02:26:25 PM
-
So for my work flow i break up my FSMs into multiple FSMs on each object.. So for my mouse over Logic:
I have one FSM for getting the actual mouse over info like mouse over or button pressed or touch on and off etc.
Another FSM for modifying the look of the object like a color change or something and then adjusting it back again.
Another FSM for displaying mouse over information on the screen like a pop up box or text etc..
What is the best way to share variables between these FSMs? I am currently using Set FSM Float etc..
I wish there were Object variables like Global variables.. I dont like clogging up my Global variables with these types of things as i find it makes it overwhelming with i look at my globals list..
Q
-
Set Fsm Float etc. is one way.
You can also send events between FSMs and use Set Event Data and Get Event Info to share information across FSMs. This is a little more encapsulated than Set Fsm Float etc. since FSMs don't have to know about each others' internal variables.
Eventually I'd like to have a shared variable - something between a local and global variable, to make it easier to share variables across cooperating FSMs. But I have to figure out how this fits in with hierarchical FSMs which would also make it easier to share variables (sub FSMs would have access to the parent FSMs variables).
-
Cool... I will look at the send event data.. But this is working for now... Sub FSMs sound cool.. now in that system is only one state active still or are there more then one active at one time?
Q
-
One state at each level would be active. Typically you'd keep the top level very simple to keep things organized and implement specific behaviors on lower levels - if that makes sense! It's actually quite intuitive in practice, but harder to describe...
-
No that makes sense to me. Kind of how i organize mine now but with multiple FSMs on each object..
Sounds cool
Q
-
Hi,
Ideally, I'd very much enjoy a variable that can be accessed by siblings AND/OR childs. That would be a very simple and intuitive way to encapsulate variables.
Also, declaring variables as being accessible for a given fsm would be good too like a kind of "include".
Bye,
Jean
-
Performance-wise, would creating an FSM that only contains variables for a specific game object be a way to manage something like this? For example:
Game Object
-FSM Click button
-FSM Setup menu
-FSM Change icon
-FSM Database (contains all of the menu variables that need to be shared in FSMs above)
I'm debating on whether to implement something like this if it helps performance.
-
Hi,
yes, that's what I am doing currently, I prefix them with "META" and I know they only host fsm variables and do not process anything. they are just repositories.
bye,
Jean
-
What is the performance like for the SendMessage? I heard I should avoid using that at all costs for mobile development?
-
Hi,
Yes, don't make too much use of sendmessage in your gameLoop, but if you use it on one stop events, you'll be fine.
sending messages is anyway only for communicating with non playmaker scripts, if that's the case, consider integrating playmaker in your script and establish more robust communication ( via custom actions, or direct access to playmaker Fsm from script etc etc)
bye,
Jean