playMaker

Author Topic: Can a custom action send its FSM to a script?  (Read 1749 times)

Coopaloops

  • Playmaker Newbie
  • *
  • Posts: 6
Can a custom action send its FSM to a script?
« on: June 27, 2014, 12:35:25 AM »
I'm in the process of writing some custom actions, and I was wondering if it's possible to have an action send the current FSM to another script in Unity. By "current FSM" I mean the FSM that contains the custom action.

The custom action I'm working on instantiates an object that needs a reference to the FSM that instantiated it so that it can send an event back to that FSM. Any ideas if that can be done?

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4003
  • Official Playmaker Support
    • LinkedIn
Re: Can a custom action send its FSM to a script?
« Reply #1 on: June 27, 2014, 01:44:11 AM »
The Fsm property in a custom action is the FSM running the action.

Coopaloops

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Can a custom action send its FSM to a script?
« Reply #2 on: June 27, 2014, 11:15:40 AM »
Thanks Alex, can you give an example of how I would send that value?

All the examples I've seen use PlayMakerFSM as the type to set fsm variables in other scripts, but I don't think I can assign the Fsm property to a PlayMakerFSM variable. Basically what I want to do is have a public variable in my script, for example:

public PlayMakerFSM myFsm;

And then assign my current fsm to that variable from my custom action.

Then I can do myFsm.Fsm.SendEvent("Event")

As it is, I'm having to specify the gameobject that the PlayMakerFSM object is on (in my playmaker custom action), and then do a GetComponent<PlayMakerFSM>() to figure out the PlayMakerFSM.

Can I have a variable that is of type Fsm? Thanks for bearing with me while I'm trying to learn this stuff!