playMaker

Author Topic: Save a state in a FSM  (Read 1143 times)

Domus

  • Playmaker Newbie
  • *
  • Posts: 6
Save a state in a FSM
« on: May 17, 2021, 03:39:11 PM »
Problem: I have a very simple game manager in my game (see attachment)

Each time a player clicks on a defined object, an event is sent to the game manager that says that this object "it was clicked". Game finish when you have clicked all the object.

I'd like to save the "state" of this FSM when the player exit the game.

Question: Is possible to let the player load the game and start this fsm with another state as a start state?
Hope what I'm saying makes sense.
I'm also experimenting with easy save to achieve that!

Thanks!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Save a state in a FSM
« Reply #1 on: May 17, 2021, 04:24:27 PM »
Hi.
You can use the system event "APPLICATION QUIT" on a separate fsm

then in that fsm use 'Get Fsm State' to get the state name.

Then when you restart the game use 'Go To State By Name' (Ecosystem)

On the fsms that you want to start from a different state you might want to change the start state.
As on enable it will already start from there.

So you could have a start state not connected to anything
and use the 'Go To State By Name' with a default value (Idle)

Domus

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Save a state in a FSM
« Reply #2 on: May 17, 2021, 04:56:55 PM »
Oh.. WOW. It works! Easy and straight to the point! Thanks!

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 773
Re: Save a state in a FSM
« Reply #3 on: May 18, 2021, 09:04:30 AM »
That's a very good case of the use of GOTO and that reminds me that Playmaker's Graph View should really provide more clues and tracking regarding the use of GOTO actions, like for example the fact that a state is actually targeted by a GOTO action, somewhere.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Save a state in a FSM
« Reply #4 on: May 18, 2021, 10:35:01 AM »
Hi.
The Go To State By Name is a custom action and 'kind of a hack'

In the backend of a fsm it uses a 'Set State' which you also can used on animator events btw.
It can't really be tracked as it just uses strings

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 773
Re: Save a state in a FSM
« Reply #5 on: May 19, 2021, 06:45:36 AM »
Indeed many things in Playmaker use strings which does prevent the tool from being self aware. Now, a global file or some proxy component of some kind that mirrors those string entries and does the linking, acting like a little database, might solve this.