Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - FrozenTarzan

Pages: [1]
PlayMaker Help / Return behavior of "Send Event" [SOLVED PARTIALLY]
« on: September 13, 2013, 01:30:36 PM »

I have a FSM, called A, that holds a reference to a gameobject. I want to change this gameobject from another FSM, called B. But I want FSM A to be able to react to the change, maybe because some exit/cleanup method has to be called. So I basically want to send an event from FSM B with the new gameobject to FSM A. Then FSM A could handle the event, call the exit/cleanup stuff and finally change its reference of the gameobject with the new one.
How could I realize this behavior?
[EDIT]: I have solved this by using the "Set Event Data" and "Get Event Info" actions. :-)

And here is an extended problem problem:
I have to send more than one gameobject to FSM A, because it holds multiple references to all kind of gameobjects/variables. So I basically want to create a custom Event with custom parameters, that can be sent from FSM B to FSM A.
Is this possible?
[EDIT]: I found this post here from jeanfabre:
-- send a event to a Fsm, that fsm will then query the caller or what it needs when it receives that events, this is much easier, but introduce some dependancies, aka the receiver has to know where to get the informations. This is solved by creating what I call "META" Fsm, that acts as data repository, so if I have a player, all my enemies have a reference of "META PLAYER" fsm, and when the player wants to comnunicate with an enemy, it send an event, with no data, and the enemy simply pull from "META PLAYER" what it needs to react and act upon this event.

What I have done right now:
FSM A holds the reference/references. FSM B sends an event "Reset gameobjects". FSM A calls some exit/cleanup stuff for the objects. Then FSM B sets all the variables directly in FSM A. But here is the danger! Is it guaranteed that the "Send Event" for "Reset gameobjects" is processed BEFORE the direct setting happens? Is it possible that FSM A (holding the data) receives the "Reset gameobjects" event and FSM B sets the variables BEFORE FSM A was able to react to the event (calling cleanup stuff)?

I come from C++ and all my FSMs were designed like this:  All generated events were pushed directly into a queue and were processed in another iteration. This is really useful, because the program flow is easy to understand. Only one iteration of events is handled at a time. The programmer could then choose if he/she wants to process an other iteration... and another... but only one set of events at a time. In this case the solution above would fail completely!

I quess all my questions are a bit confusing, but being a programmer I need to know a lot of the technology underneath, so we don't run into problems later on.


Hi there,

I have searched a lot now and found a few posts that target the same problem, but there was no good answer yet. See here:

I want to receive events from a PlaymakerFSM. Ideally direct events and broadcasted events.

There is an action called "Send Event", where I can choose to send an event to a "GameObject". But how do I listen to this event in my script/gameobject? Especially to custom events created by myself?

But even if I could get the "Send Event" action working, how do I listen to broadcasted events?

The workaround would be to create a dummy FSM for my gameobject and forward all events with the "Send Message" action. But this seems to be hacky, right?!

Hi Playmaker community,

Let's say I have a component for a fighting-tower with a custom AI. The tower has a mesh that can "look at" a target position and has a component that handles the internal behaviors like "seek and destroy", "offline", "follow target peacefully", "turn around as fast as possible and shoot like there is no tomorrow".

Without Playmaker I would design a FSM with code. So When the Update() of the tower is called, I would call the FSM.Update() method, which would use polymorphism to call the correct Update() method of the current state.

Now how would I use Playmaker to represent such a FSM with the visual Playmaker window?

Possibility 1: Use the internal FSM for the tower as usual and just use the events from playmaker to handle the state-changes. The communication could happen by calling a method with the "Send Message" action. But this way I still have to use my own FSM implementation.

Possibility 2: Use the FSM from Playmaker and all the events and so forth. Then in the Update() of the tower, I have a lot of if/elseif/switches that check for different parameters and adapt the behavior. Like an enum with SeekAndDestroy, Offline,... This way I can set the parameters directly via actions from Playmaker (like Set Float Value,...) but the internal design is ugly.

Possibility 3: Use custom actions for each state I can be in. So I would pass the original GameObject (the tower) to the action and this action would encapsulate the behavior? It would be like passing the tower to a generic implementation of state design pattern. In this case I would have a custom action for each state the object can be in?

Possibility 4: ...insert your best solution here! ;-)

I'll try to reformulate my problem: When I have an object that behaves differently in different states and this object has to handle code (more complex than the predefined Playmaker actions) in an Update() routine, how do I design an appropriate FSM with playmaker?

Pages: [1]