playMaker

Author Topic: Save/load last scene played  (Read 1376 times)

Seiryu33

  • Full Member
  • ***
  • Posts: 133
Save/load last scene played
« on: August 01, 2017, 03:25:01 PM »
Hi! Revamping my save system to be more efficient. I'm using EasySave2 and I'm trying to see if there's a way to save the last scene that was played so that the next time the game plays it'll load from the last scene that was played. Not entirely sure how to set that up. Any suggestions?

Deek

  • Full Member
  • ***
  • Posts: 133
Re: Save/load last scene played
« Reply #1 on: August 01, 2017, 04:45:27 PM »
One of the latest PlayMaker-Updates included scene-related actions, of which you can use Get Scene Name or Get Scene Build Index to store the current Scene in PlayerPrefs or EasySave2 and in your first scene the first thing you do is get that String or int, use Load Scene and insert that variable to load the last scene you visited before leaving the game.
You can also make a dummy scene as your first one that only is there to check which scene was the last one and if none was saved (a.k.a. if it's the first time playing) load the scene that would normally load as the first one.

If you use an earlier version of PlayMaker, you can download Get Active Scene Name from the Ecosystem and use Load Level (which was used in previous PlayMaker-Versions and is now deprecated) or download Load Level2, also from the Ecosystem.

To always only save the current level when the scene got changed, right-click on that state that saves the current scene, choose Add Global Transition>System Events>LEVEL LOADED.
This Event gets fired whenever a new scene gets loaded, but it might've also just been added in one of the later PlayMaker-Versions, so it's probably best to update if you haven't already.
It's also best to separate that action from everything else, so that it only processes the saving of the current scene when changing it.

If you want to be able to load the previous scene in-game without exiting you'd have to save every visited scene while visiting in an array, then you have an array of all visited scenes and just get the fore-last entry, but since that wasn't the question I won't elaborate further.

Hope that was what you asked for.