playMaker

Author Topic: SetState Before FSM start  (Read 1644 times)

densy

  • Playmaker Newbie
  • *
  • Posts: 1
SetState Before FSM start
« on: March 23, 2018, 04:49:15 AM »
Hi,
    Can I use the PlayMakerFSM.setState to change my default state before the FSM start?

    After I do that, the PlaymakerFSM will call the PlaymakerFSM.Fsm.Start(), it will trigger the current state exit and enter again. So my target state will trigger twice.
   
    To prevent this, my code is
Code: [Select]
if (m_fsm.Fsm.Started == false) {
                m_fsm.Fsm.Start ();
            }

            if (state != m_fsm.ActiveStateName) {
                m_fsm.SetState (state);
            }

    Is that right? It's my first time to use Playmaker. Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: SetState Before FSM start
« Reply #1 on: March 26, 2018, 02:05:01 AM »
Hi,

 no, you can't change the Start state programmatically.

 Instead, make your state state an Empty state, and then you can control the fsm safely.

 you might have to wait one frame for things to have time to inititalize.

Bye,

 Jean