playMaker

Author Topic: How to save current state of fsm and then load it back again after app restart  (Read 526 times)

GMPlay

  • Playmaker Newbie
  • *
  • Posts: 28
Hello,

I am working on a 3d first person PointNClick Adventure game. So naturally there are numerous puzzles in this project.

I will detail out my query by using an example of a %u2018Treasure Chest%u2019 and referring to it as a %u2018Puzzle%u2019

To solve the treasure chest puzzle  there are multiple states that it needs to go through.

STATE1: Initially the chest is in %u2018locked%u2019 state.

STATE2: Player needs to have its key in the inventory. So that we can drag it from there and then drop it on the chest. If the key is correct the chest puzzle will advance to the next state. We can call this state %u2018key-inserted%u2019. In this state the key will appear inside the keyhole, sitting idle.

STATE3: Next, the player would have to interact with the key itself to turn it. Clicking it once will turn it. This will advance the puzzle to next state which is %u2018unlocked%u2019.

STATE4: Now the player has to slide or lift the latch to free the chest-lid. Lets call this state %u2018unlatched%u2019

STATE5: The player can now interact with the lid, lift it up and open the chest. Let us call this state %u2018opened%u2019

STATE6: There is reward item inside, the player can interact with it to pick it up. As soon as the item disappears from the scene the puzzle is advanced to it%u2019s final state which is %u2018solved%u2019

My Requirement:
I need to design these puzzles such a way that at any given time when there is a change in the state, it should be preserved so that when the game quits, it can be resumed from there.

For example if the player has managed to put the key inside key-hole (at STATE2) and hasn%u2019t turned it yet, then if the application quits, the state of the puzzle needs to be exactly where it was. Meaning, the key should still be there after the app is loaded again, waiting to be turned.

Query1:
What is the design approach to fsms for puzzles so that I can save various states. Please note that I have EasySave3 asset with me. And I have fair bit of understanding how to use it in its basic form. But I am not sure how to %u2026let%u2019s say start an fsm from a state that is somewhere in the middle of an fsm. Is it possible to load last state of fsm from savefile and continue from there?

Query2:
One more concern I have is that let us say there is a sliding puzzle that has multiple pieces of various shapes and sizes with different combinations of orientation etc. What is the best way to design such a puzzle using fsms such that all their states can be saved collectively without having to deal with each and every piece individually?

Also if there are any examples or tutorials available, please provide some links.

Thanks in advance!
« Last Edit: September 03, 2022, 01:54:47 AM by GMPlay »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Hi.
you could use a int and set a unique int number for each state, or use the state name.

there is a custom action on the ecosystem call Go To State By Name.

at the beginning of your fsms load the saved string and then use the "Go To State By Name" to go directly to that state.

you might need to set some separate states to go to as you might visually need to set the key in the hole for example.

if you would end in state 3 for example and did not interact yet , you safe a string called (for example) 'Start State 3'
then make a state called  'Start State 3' and in that state, set the required visuals (place key in the hole)

there might be other ways doing this :)

GMPlay

  • Playmaker Newbie
  • *
  • Posts: 28
Seems like an approach that is worth trying. This would be a good starting point.

Thanks! ;D