playMaker

Author Topic: Setting a PlayMakerFSM Component's FSM via script [SOLVED]  (Read 1247 times)

paradoxjester

  • Playmaker Newbie
  • *
  • Posts: 12
Setting a PlayMakerFSM Component's FSM via script [SOLVED]
« on: July 26, 2018, 04:34:19 AM »
Hey everyone,

I'm creating some editor scripts in unity, and i was asked to set a PlayMakerFSM component's inner FSM value to be the instance of a FSM Template. This FSM Template is stored in a Scriptable Object, and when the Scriptable Object is assigned to the GameObject, then the FSM value of the PlayMakerFSM component should change. I don't want to set the PlayMakerFSM's template to be the FSM Template, i want the inner FSM to be a copy of the FSM Template. I can extract an instance from the template using the FsmTemplateControl class, but i don't know how to insert it in the component.
Can anyone help? I'd be very grateful ,:D
« Last Edit: August 17, 2018, 10:12:41 AM by paradoxjester »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Setting a PlayMakerFSM Component's FSM via script
« Reply #1 on: July 27, 2018, 09:44:40 AM »
Hi,

 you need to call <PlayMakerFSM>.SetFsmTemplate(templatePointer);

then that FSM will use the template.

 I am not sure if I follow your sentence on :

"I don't want to set the PlayMakerFSM's template to be the FSM Template, i want the inner FSM to be a copy of the FSM Template"

Are you planning on modifying the fsm state and transition at runtime?  if not, then a FsmTemplate reference will be fine.

 Bye,

 Jean

paradoxjester

  • Playmaker Newbie
  • *
  • Posts: 12
Re: Setting a PlayMakerFSM Component's FSM via script
« Reply #2 on: August 17, 2018, 07:21:38 AM »
Hi,

Thank you for answering. This is not something i planned on doing at runtime, instead i'm doing this via editor. I want to copy the contents of a template (its states, transitions and events) into the FSM of a PlayMakerFSM component, but breaking off the reference to the original template, this way if the component's FSM is modified, it will not modify the original template's FSM. I have achieved this by copying all of the Template's states, events and transitions individually into the component's FSM. Everything seems to be working correctly!
Thank you again!