Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: FritsLyn on May 17, 2017, 03:20:48 PM

Title: Finate State Machine with multiple Rigidbodies as Children - problem
Post by: FritsLyn on May 17, 2017, 03:20:48 PM
First: Sorry if this is Repeat / Old / Obvious, the nature of the words involved here makes it really hard to search without drowning in irrelevant results.

In a mainly C# project, I want to use PlayMaker as a pure FSM:

Each NPC has a rigidbody and Playmaker at root, and a couple of rigidbodies and triggers as children.

Playmaker is to be used to make it easy to oversee the rather complex behaviour and order of all things going on below. Most action is happening in multiple scripts.

I want to make only 1 FSM (the goal here is not to make a new complex layer, but to tidy up all the stuff below)

Problem:

Apparently it's not easy to work with Trigger Enter Events on children, independent of root?!?

All things Trigger Enter related are sort of just hooking up to Root: ON TRIGGER ENTER does not have any options to set WHO the trigger is.

Drag-dropping GameObject with a collider and finding the collider / Trigger via the popup menus one way or the other does work: I can get On Trigger Enter from another collider.. but..

A) The event info in the State window does not say who the Trigger belongs to (minor issue)

B) If there's more than one of such unnamed On Trigger Enter entries, then apparently the whole system mixes up what is who and where, and depending on another On Trigger Enter being switched on/off, another one will change behavior..

Is there really no good / clean way of using Playmaker as an overlaying FSM reacting to multiple & different child ON TRIGGER ENTER in same FSM without making spaghetti?

Title: Re: Finate State Machine with multiple Rigidbodies as Children - problem
Post by: FritsLyn on May 18, 2017, 02:39:13 AM
For the Next looking for this: There is a good solution:
On your triggers etc, set up simple snippets such as this: under for example OnTriggerEnter()
theFsm.SendEvent(myName + " Hit Player");
Your events does not even have to be global - this works wonders and is very, very intuitive and readable.
Read on places like this:
http://hutonggames.com/playmakerforum/index.php?topic=1355.0
and this:
https://matthewwaring.wordpress.com/2014/01/14/using-playmaker-with-code-quick-introduction/