PlayMaker Help & Tips > PlayMaker Help

GetFsmFloat vs GetEventInfo/SetEventData

(1/3) > >>

krakov73:
Getting some weird results so I thought i'd ask :)
 
On one game obj I'm trying to send a float on one fsm to another fsm on the same object. This float is changing every frame, and when I use set event data/get event info the receiving fsm receives zero (what the float starts as) while I can see the float changing in the set event data debug. If the float is static it sends just fine so it only seems to send what the float is set for on the first frame of the state even though the send event every frame is ticked.
To get round this I'm using GetFsmFloat on the receiver instead that works fine but adds to the ever growing stack of actions in a single state (more on that later).
 
So if you can follow what I've been saying (this stuff is hard to describe) I need to know the right way of sending changing data between fsms, there are lots ways of doing this in playmaker but there seems to be no guide to best practise in different contexts yet playmaker seems to be all about sharing data between fsms's & objects.
 
Related to this (but maybe it needs a new thread) is my problems with actions stacking up in single states. I'm having trouble keeping my states legible particularly every frame states where I cant seem to split them up as they are reliant on things happening within that state (mouse up event/every frame bool checks for instance) I've read some threads on this but I'm not finding good examples of splitting states into more manageable sizes so any help on that would be super nice ;)

Edit: Sorry if this was a bit rambling, i've added an example & i'll just ask if it is correct/expected behaviour - I was thinking both mouse buttons would do the same thing in this case.

krakov73:
Well excuse me for not having esp because when the manual is so tight lipped on when & where to use seemingly duplicate actions (and pretty much everything else) I have no choice but to ask in the forums - i'll be bumping this thread regularly.

jeanfabre:
Hi,

Sending data with events works in 99% of the case and I think you fall in that case. I think it's simply a matter of wrong state or logic set up.

 the only case where event data do not work reliably is the following:

 if two objects have colliders and for example trigger enter or collision enter is fired and both object have Fsm implementing a send event with data in the state then the data is mixed up. I have a repro case that I need to clean up. I bumped into this problem only twice since the beginning of playmaker.

In this case, the best option is to manually set a variable in the target Fsm and then fire the event. Event data should not be used in that case. In the mix comes Prefab instantiation and Start state that also should be avoided. Don't rely on the start state when you know the Fsm is on a prefab amd relies on early set up when instantiated, instead do as above as well, set variables manually using set Fsm xxx actions and then either wait for a frame or send a "INIT event to that FSM at a later time.

 So:
-- are your fsm attached to a physics gameObject using colliders?
.. Are you within the START state and its flow?


I do have a lot of fsm that relies on others indeed, and for this the best approach I found was to maintain a "META" fsm only holding them shared variables, they do not implement any logic or receive any events, they are simply repositories. Other Fsm get and set what they need there, so I know that I NEVER rely on a variable within a Fsm, but actually always rely on the "META" variable value instead. So when I enter a certain logic, I first make I get all the variable I need and then proceed. It doesn't have to be bad Fsm with twisted logic, I think mine are very organized and flows very well actually. The Get / set fsm variable dance is annoying for sure, and the way to go about that is to split States indeed.

splitting states that should work everyframe can be sometime a challenge, and for this, it's not about splitting the state, but actually splitting the Fsm all together.

EveryFrame bool states and similar technics is not very nice. I do use them, but only very occasionnally, when I can't be ask to do it proper to be honest... :) and then I know I will have to re do them cause they are a pain to maintain and not flexible. When you switch a boolean variable state, you should fire a global event for other Fsm to listen and avoid too much "every frame states" this way everything flows much better, you visually see and understand when a state cane exit and why.

Do you have particular examples? that would help base this discussion on fact and provides tangible alternartives for users to understand these design patterns.

Bye,

 Jean

krakov73:
Hi Jean thanks for taking the time with that explanation, good info in there. I think your right and its a logic problem or structure problem I'm running into.

I'm still confused about get/set event info and how is supposed to work given what its showing me on screen.

In my example in the OP if you hold down left mouse you can see the float changing very frame in its set event data debug window...here is a screenie -

http://imageshack.us/photo/my-images/854/senderr.jpg/

Yet in the reciever fsm the get event data does not get updated when this is happening...

http://imageshack.us/photo/my-images/841/recievers.jpg/

so I've got to wonder why the send event action has an very frame tick box if its just a switch & can't be used for data transport every frame - however I'm comming round to the fact that transporting data every frame is my structure problem & not playmakers :)

Now when you describe your 'META' fsm I'm reminded of a couple of threads that mentioned using 'broker' fsms (by you I think), this could be where my disconnect is because i'm still thinking to much in scripting terms & making functions inside fsms where I shouldn't hense the communication & stacking issues.

In this context i'm making character objects with player controls or ai, health, energy, shields etc but the all import part is my desire to integrate a playmaker animation graph that keys off of these components. Could I trouble you to sketch a flow chart so I could visualize how or where the META fsm would sit between components like these & typical actions for communication between them.

Also thanks again for your previous help on health bars, thanks to that now my problems are not making things happen with playmaker but doing them the right way :)

jeanfabre:
Hi,

 the everyFrame option do not work on the Send Event action. It's a bug.

 I would actually also not send event everyframe. I don't feel this is appropriate.

rathet, I would send an event to start watching for a variable, and an event to stop watching for it.

and the fsm that was suppose to get the event and it's data, would simply get the variable value either from a global variable, OR using "get Fsm int" or something.

Does that make sense?

bye,

Jean

Navigation

[0] Message Index

[#] Next page

Go to full version