playMaker

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

fysa

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Sharing a FSM with multiple prefabs
« on: March 23, 2011, 05: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, 05:42:03 PM by fysa »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3632
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Sharing a FSM with multiple prefabs
« Reply #1 on: March 23, 2011, 06: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
    • View Profile
Re: Sharing a FSM with multiple prefabs
« Reply #2 on: May 30, 2013, 09:25:47 PM »
Hi any news about the after mentioned "AddFSM" action?