playMaker

Author Topic: how to set State (not send event) from a script?  (Read 3666 times)

mindlube

  • Playmaker Newbie
  • *
  • Posts: 32
how to set State (not send event) from a script?
« 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
« Last Edit: July 30, 2012, 06:27:29 PM by mindlube »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: how to set State (not send event) from a script?
« Reply #1 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

congson1907

  • Playmaker Newbie
  • *
  • Posts: 1
Re: how to set State (not send event) from a script?
« Reply #2 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

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: how to set State (not send event) from a script?
« Reply #3 on: December 07, 2017, 01:13:49 PM »
Hi congson1907.

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