playMaker

Author Topic: Sharing a FSM with multiple prefabs  (Read 3250 times)

fysa

  • Playmaker Newbie
  • *
  • Posts: 2
Sharing a FSM with multiple prefabs
« on: March 23, 2011, 08:40:32 PM »
Looking for the 'official' way to accomplish something like this with Playmaker ..

I will have NPCs and mobs with multiple layers of FSMs .. sort of an FSM hierarchy:

- lowest level is core fight-or-flight responses .. e.g. extreme panic/rage/fear.

- next level will have basic reasoning/needs (following pathfinding waypoints, following goals)

- next level is more advanced reasoning (+ fragmaps, setting intelligent waypoints/goals/personal objectives)

- and then squad-interaction above that (+ squad information/fragmaps, coordinating multiple waypoints or objectives)

I would like to be able to share the lowest-level FSM with creatures of all types -- whether an NPC or a pig, without needing to re-implement it manually for every prefab.

Should I simply create a GameObject to represent each of the FSM levels, prefab them independently, and then attach that prefab to the other prefabs?

Or is there a way to export/import an FSM between GameObjects?  I can have multiple on a single GameObject, but can I easily export from one and import into another?

If you had a serialization class/function (e.g. JSON-like) and an API/method to store/retrieve, then I could apply the proper FSMs in code as needed -- so that may be a reasonable item for a request list.  I do not need Playmaker to generate code .. I really just need access to it as a giant object/array or class structure.

Thanks for creating such a useful tool -- you are certainly on the right track.

Regards,
Jason
« Last Edit: March 23, 2011, 08:42:03 PM by fysa »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Sharing a FSM with multiple prefabs
« Reply #1 on: March 23, 2011, 09:22:44 PM »
Hi Jason,

Assembling a creature from a collection of prefabs is probably the best way to do this at runtime right now.

At edit time you can copy/paste FSMs and create Templates that can be quickly applied to objects. Copy/paste and templates are much improved in the 1.1 update - you can copy/paste whole FSMs, and even select multiple objects and apply a template to all of them in one step. And the variable copying bugs have been fixed!

We are looking into some runtime equivalent of adding a template (e.g., an Add FSM action). I'll keep you posted as we investigate that...

Cheers,
Alex

Tochas

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Sharing a FSM with multiple prefabs
« Reply #2 on: May 31, 2013, 12:25:47 AM »
Hi any news about the after mentioned "AddFSM" action?