playMaker

Author Topic: Is there a C# event or callback when a state change occurs? [SOLVED]  (Read 3125 times)

GarthSmith

  • Playmaker Newbie
  • *
  • Posts: 31
  • Games. Math. Code.
    • Garth Smith's Website
Hello!

I want to know when my state machine has changed states. I have some custom actions that have this code in them:

public override void OnEnter() {
    Owner.SendMessage("OnNewState", Fsm.ActiveStateName,
    SendMessageOptions.RequireReceiver);
}


There are some problems.
  • This only works on my custom actions, not on any actions that come with PlayMaker.
  • If a state has multiple of these actions attached, the "OnNewState" message is sent multiple times.
  • I must make sure that every single state has an action that sends the message "OnNewState" or else I'll miss a state change. This can become a problem for larger projects.
Is there some PlayMaker API that announces when a state change has occured?
« Last Edit: September 13, 2013, 03:55:42 PM by GarthSmith »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Is there a C# event or callback when a state change occurs?
« Reply #1 on: September 13, 2013, 05:35:41 AM »
Hi,

 What are you trying to achieve when willing to know when a state changed on an fsm?

It's important to understand the context of your need, it may be already possible to solve this as is.

bye,

 Jean

GarthSmith

  • Playmaker Newbie
  • *
  • Posts: 31
  • Games. Math. Code.
    • Garth Smith's Website
Re: Is there a C# event or callback when a state change occurs?
« Reply #2 on: September 13, 2013, 03:55:16 PM »
I'm marking this as [SOLVED].

We had two parts, a movement FSM and an animation system.

Our animation system was built separately and it reacted to the non-PlayMaker FSM state changes.

Your question made me realize that instead of our Animation system being aware of our movement system, we can go the other way and make our PlayMaker movement system send commands to the animation system.

Thanks!