playMaker

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

mindlube

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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12405
  • Official Playmaker Support
    • View Profile
Re: how to set State (not send event) from a script?
« Reply #1 on: July 31, 2012, 12: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
    • View Profile
Re: how to set State (not send event) from a script?
« Reply #2 on: December 07, 2017, 08: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: 2393
    • View Profile
    • jinxtergames
Re: how to set State (not send event) from a script?
« Reply #3 on: December 07, 2017, 11:13:49 AM »
Hi congson1907.

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