Playmaker Forum

PlayMaker News => General Discussion => Topic started by: densy on March 23, 2018, 04:49:15 AM

Title: SetState Before FSM start
Post by: densy 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!
Title: Re: SetState Before FSM start
Post by: jeanfabre 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