playMaker

Author Topic: How would you check if a Gameobject has an FSM of a certain name?  (Read 1407 times)

MikeTelly

  • Playmaker Newbie
  • *
  • Posts: 40
I basically want an event to only be sent to an object if it has an FSM with a specific name. I'm not exactly sure how to do this though. I've tried using an action from the Ecosystem called "Get FSM Component" but it doesn't seem to be working.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How would you check if a Gameobject has an FSM of a certain name?
« Reply #1 on: July 02, 2018, 07:47:54 AM »
Hi.
Can you give some more details on what you are trying to do, maybe there is a different way to do this.

I think the way you are trying now is not good for performance.

are these object spawned @ run-time

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How would you check if a Gameobject has an FSM of a certain name?
« Reply #2 on: July 03, 2018, 02:30:40 AM »
Hi,

 Indeed, it's not possible to do that, as a built in way in PlayMaker.

One way to go about this is the following:

your fsm that wants to listen to a particular global event based on logic, should have that global event as a transition of a state. and so this event will only be triggered on that fsm if it is on that state, this is very powerful indeed.

 so if you send a global event "HELLO", and a fsm has its active state with the transition "HELLO" it will work, however that same fsm if it was on a different state at the time of call, would not have the transition triggering anything. It's only global transition ( when above the state) that works no matter which is the active state.

 Does that make sense? this way, in your fsm logic you can start listening or stop listening to a global event this way.

 However, this comes from the listener, not the Sender. If you want the sender to control to whom to send events, then you will need something more complex, for example a registration system, where fsm register themselves to a manager, and then senders contact the manager and say, I want to send this event to this fsm, and the manager look up its list of registered fsm and send that event to the right one.

 Bye,

 Jean