playMaker

Author Topic: Custom Action Question  (Read 1608 times)

mathius777

  • Playmaker Newbie
  • *
  • Posts: 38
Custom Action Question
« on: June 11, 2013, 11:19:00 PM »
Hello. I would like to write a custom action that has a looping type behavior. I have an npc, and I'd like to write a high level action "Find Exit", so that I can add this action to a state that an NPC is in and it will keep moving towards the exit every update. Is this possible?

I know people would probably say to have lower level actions, but to me it made sense to do all the complex logic(actually calculating where the exit is, and moving towards it) in a script, and then in PM I can see at a high level view what the NPC is doing.

Thank you.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Custom Action Question
« Reply #1 on: June 19, 2013, 07:32:14 AM »
Hi,

 you simply need to use "Fsm.Event()" function to exit your state.

 look at the various existing actions to see how it's implemented, for example "BoolTest"

The key is to process your logic in "OnUpdate()" function, and simply fire your event when ready.

But it's true, you should design your logic within a fsm and a series of states, not necessarly within one action, but it's totally possible, and likely make sense in your case.


bye,

 Jean