playMaker

Author Topic: How to deal with multiple children FSMs  (Read 1505 times)

barjed

  • Playmaker Newbie
  • *
  • Posts: 1
How to deal with multiple children FSMs
« on: February 09, 2014, 12:11:53 PM »
Hello,

I am curious what is the best way to handle access to multiple FSM children of a GO? Here's a simple example of my setup:

- goLogic
-- fsmDatabase
-- fsmMovementMode

- goCamera
-- fsmDatabase
-- fsmBehavior

Now both of the empty game objects have C# scripts attached to them that are used to easily tinker with various setting in the Inspector (for example, Camera has CameraProperties.cs that lets you specify TrackingTarget, FOV, etc.). Databases reference those scripts, pull the properties and share them with other FSMs of the same GO (I think I have read about this idea in of Jean's post - thanks!).

The issue is in referencing these nested FSMs from another GameObject. For example, I want fsmMovementMode to send an Event to fsmBehavior in order to change camera mode.

Because fsmBehavior is nested inside goCamera, I cannot simply call Send Event, as the object itself has no FSMs. The only way I can think of is using Get Child, but that seems extremely clunky because you either have to specify a tag (the list would quickly grow) or search by string (ewwwww!).

I would be extremely grateful for some tips from Playmaker pros :)

Cheers!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to deal with multiple children FSMs
« Reply #1 on: February 10, 2014, 03:23:40 AM »
Hi,

 I would go for implement some global events. This is in my opinion the most reliable and trouble free solution.

 Typically, it's ok to create a global to allow a set of fsm to communicate together. and to organize global events cleanly, I use a "/" separator in the event name itself so that in various selection dropdown it stays manageble, so you would have something like:

CAMERA / DO THIS
MANAGER / DO THAT

also, make use of event's data, use the action "set event data" to pass information with the event and on the reception side use "Get event info" to retrieve this data. for more complex data events, search the forum ( when it's back on) for "event data properties", I created a system where you can add any properties and values you want, not just a fixed amount.

Bye,

 Jean