Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: mindlube on July 30, 2012, 06:17:51 PM

Title: how to set State (not send event) from a script?
Post by: mindlube on July 30, 2012, 06:17:51 PM
I need to resume/load an FSM which I have loaded from disk or got from network play.
It could be as simple as
FSM.SetState( "name" ),  which doesn't exist in the api that I can find.
and
FSM.ChangeState() takes an Event parameter, not a state name.
FSM.ActiveStateName is read-only property.

The only alternative I can see is to make a global transition  ( like "resume {state name}" ) to be able to re-enter arbitrary points in the state machine? Thats a lot of tedious editing of new nodes in my graphs  :P This seems time consuming, so please give suggestions or what am I missing? thanks!  ;D
Title: Re: how to set State (not send event) from a script?
Post by: jeanfabre on July 31, 2012, 03:17:13 AM
Hi,

 Yeah, currently you will need to fire a Global Event to enter a state, even with the api. Maybe future version of playmaker will allow and even implement some features to have more control over resuming.

bye,

 Jean
Title: Re: how to set State (not send event) from a script?
Post by: congson1907 on December 07, 2017, 10:18:03 AM
GetComponent<PlayMakerFSM>().Fsm.GetState("State1").Name = "NewStatename";
//the current name of the state, for example, is State1
Title: Re: how to set State (not send event) from a script?
Post by: djaydino on December 07, 2017, 01:13:49 PM
Hi congson1907.

If you need the current state name you need
Code: [Select]
Fsm.ActiveStateName