Understanding how to Use Save System Slots

Announcements, support questions, and discussion for Save System for Opsive Character Controllers.
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

Understanding how to Use Save System Slots

Post by nathanj »

Hi Tony,

been a while, hope you are well.

Setting up the save system for the first time and a massive thank you for doing this, it saves me a lot of hassle ;)

Is there an example or outline of how you would go about allowing users to create new instances of saved games and load those instances with this system? I'm just trying to get my head around the loading and saving of slots dynamically and how i invision things is often between 90 and 130 degrees from intended use, so before I start going down a path I was wondering if there was any documentation on this process before.

Thanks as always,
Nathan
User avatar
Tony Li
Posts: 22200
Joined: Thu Jul 18, 2013 1:27 pm

Re: Understanding how to Use Save System Slots

Post by Tony Li »

Hi Nathan,

Slot numbers are really just unique numeric identifiers, kind of like arbitrary dictionary keys. They don't have to be sequential. You could save games in slots 1, 7, and -63 if you want.

The Save System for Opsive is primarily a back-end data/system asset. It ships with a very simple test script that always saves to a single slot number. It's up to you to provide a UI to allow the player to specify which slot(s) to save/load.

For an example, you can look at the Dialogue System's free Menu Framework addon available on the Dialogue System Extras page. It's a front-end for the Save System and Dialogue System that allows the player to save and load games to different slots.
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

Re: Understanding how to Use Save System Slots

Post by nathanj »

Perfect,

Thanks Tony
User avatar
Tony Li
Posts: 22200
Joined: Thu Jul 18, 2013 1:27 pm

Re: Understanding how to Use Save System Slots

Post by Tony Li »

Glad to help!
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

Re: Understanding how to Use Save System Slots

Post by nathanj »

Hi Tony,

Apologies is this is an obvious question, how to I retrieve all used slots from the Save System?

I'm trying to do a check on start to populate a ui panel with buttons for each saved instance and I can not figure out where this is stored.

Thank you,
Nathan
User avatar
Tony Li
Posts: 22200
Joined: Thu Jul 18, 2013 1:27 pm

Re: Understanding how to Use Save System Slots

Post by Tony Li »

Hi Nathan,

You can look through the number of slots you allow and check SaveSystem.HasSavedGameInSlot(#):

Code: Select all

for (int slot = 0; slot < MaxSlots; slot++)
{
    if (SaveSystem.HasSavedGameInSlot(slot))
    {
        Debug.Log($"Slot {slot} has a saved game.");
    }
}
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

Re: Understanding how to Use Save System Slots

Post by nathanj »

That’s exactly what I was looking for. Thank you!

Nathan
User avatar
Tony Li
Posts: 22200
Joined: Thu Jul 18, 2013 1:27 pm

Re: Understanding how to Use Save System Slots

Post by Tony Li »

Happy to help!
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

Re: Understanding how to Use Save System Slots

Post by nathanj »

Hi Again, Tony

having a strange issue where data seems to be shared between users for the first few times that they enter. For example, I have 5 alocated slots for users to chose from. If player one logs in to slot 1 and saves and then player two logs into slot 2 they start where player one left. If they save and then player one logs in again they are where player 2 left. But then when player two logs in again they are where they left, not where player 1 left.

From that point on they are independant and their save systems work. But up to that point there is some overlap. Can you think of what might be causing this?

To log into a saved game I call

Code: Select all

 SaveSystem.LoadFromSlot(slot);
To load in if there is no saved game in the slot I call: SaveSystem.LoadScene("Maiwar2k_SP");

and to save I'm calling

Code: Select all

SaveSystemManager.SaveSlot(slot);
My components in my loadscene look like this:
Image
Image

One thing I am not sure exactly about, but it seems to be working, is the UISSaver when I have the Save System and Dialogue System as persistent and the UIS in the scene. But, as I said, at the moment that seems to be fine. At the moment it's just getting the player's to have unique saving data from the start.

Any ideas what I could be doing wrong?

Thank you as always,
Nathan
User avatar
Tony Li
Posts: 22200
Joined: Thu Jul 18, 2013 1:27 pm

Re: Understanding how to Use Save System Slots

Post by Tony Li »

Hi Nathan,

Untick 'Restore State On Start'. In general, this checkbox should almost never be ticked.

When a player logs out, call SaveSystem.ResetGameState() to clear old save data from memory.

If that doesn't help, what aspects of player one is player two inheriting? GameObject position? Inventory contents? Dialogue System variable values?
Post Reply