Continue last save/preview saves

Announcements, support questions, and discussion for Save System for Opsive Character Controllers.
tabtaste
Posts: 16
Joined: Fri Oct 07, 2022 11:46 am

Continue last save/preview saves

Post by tabtaste »

Hey all.

1. How can i create a button that appears only wen a save exist. if more then 1 save exist i will load the last save. like a continue butto.

2. how can i preview my saves. a want to create a list with a max of 4 saves and show a picture, savedate and complete status from this save. how can i get infos from a save from slot without loading the save from slot.

greetings!!!
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Continue last save/preview saves

Post by Tony Li »

Hi,
tabtaste wrote: Fri Oct 07, 2022 11:50 am1. How can i create a button that appears only wen a save exist. if more then 1 save exist i will load the last save. like a continue button.
When you save a game, also set a PlayerPrefs key to the slot # of the save. Example:

Code: Select all

SaveSystem.SaveToSlot(slotNumber);
PlayerPrefs.SetInt("Last Slot", slotNumber);
You can add a script with a Start() or OnEnable() method to the button that checks the PlayerPrefs value:

Code: Select all

bool hasLastSave = PlayerPrefs.HasKey("Last Slot") && SaveSystem.HasSavedGameInSlot(PlayerPrefs.GetInt("Last Slot"));
gameObject.SetActive(hasLastSave);
tabtaste wrote: Fri Oct 07, 2022 11:50 am2. how can i preview my saves. a want to create a list with a max of 4 saves and show a picture, savedate and complete status from this save. how can i get infos from a save from slot without loading the save from slot.
Please see: How To: Include Summary Info In Saved Games
tabtaste
Posts: 16
Joined: Fri Oct 07, 2022 11:46 am

Re: Continue last save/preview saves

Post by tabtaste »

thanks for the great reply!

one more question. can i change the destroy saver status from a or all objects?

i try to setup a enemy handling like in souls like or hollow knight. enemys still dead between scene but when saving. all enemys except bosses respawn.

greetings
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Continue last save/preview saves

Post by Tony Li »

Yes. UNtick the DestructibleSaver's "Save Across Scene Changes" checkbox. It will only save the enemy's destruction status if the player saves and loads in the same scene. If the player moves to another scene and then returns, it will not use the DestructibleSaver's destruction status.
tabtaste
Posts: 16
Joined: Fri Oct 07, 2022 11:46 am

Re: Continue last save/preview saves

Post by tabtaste »

Okay thank you but that not what i mean.

What i try to implement is:
Enemy destruction Status should saved between scenes. Also wen i save and load.

I whant reset This Status in a specyfic case. In my case every time wen i save. Wen i save / on a specific trigger all enemys destroction status should be reseted. After This reset wen I loading a scene the emenys in This scene should spawn again

Greetings
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Continue last save/preview saves

Post by Tony Li »

Hi,

If you want a trigger to reset saver data, you can delete the saver's data. For example:

Code: Select all

public List<Saver> saversToReset; // <- SET IN INSPECTOR

void OnTriggerEnter(Collider other)
{
    if (other.CompareTag("Player"))
    {
        saversToReset.ForEach(saver => SaveSystem.currentSavedGameData.DeleteData(saver.key));
    }
}
tabtaste
Posts: 16
Joined: Fri Oct 07, 2022 11:46 am

Re: Continue last save/preview saves

Post by tabtaste »

Okay thanks. In This way i need to assign every Single enemy in the Inspektor right ? Can i Do a easy way to collect All "destructable saver" in the hole game?

Greetings
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Continue last save/preview saves

Post by Tony Li »

Yes, you could do this:

Code: Select all

void OnTriggerEnter(Collider other)
{
    if (other.CompareTag("Player"))
    {
        foreach (DestructibleSaver saver in FindObjectsOfType<DestructibleSaver>())
        {
            SaveSystem.currentSavedGameData.DeleteData(saver.key));
        }
    }
}
[EDIT: Don't use this. See below for working solution.]
tabtaste
Posts: 16
Joined: Fri Oct 07, 2022 11:46 am

Re: Continue last save/preview saves

Post by tabtaste »

thanks!
great tool, great support!

greetings
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Continue last save/preview saves

Post by Tony Li »

Thanks! Happy to help.
Post Reply