Saving At Save Points

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
DrewThomasArt
Posts: 60
Joined: Thu Mar 24, 2022 12:07 am

Saving At Save Points

Post by DrewThomasArt »

After looking around it seems there are a few ways to save but I was hoping someone could point me in the right direction for my purposes, because I've found myself overwhelmed at 2:00AM and could use some guidance.

I have a game object that asks the player (in conversation) if they want to save the game and set this point as their "save point" (respawn point.)
So is there a way for me to call this from a conversation through the sequencer? Something like this, calling Save Slot from an object with the Save System Methods component?
SendMessage(SaveSlot,,gameObject);
{{defaultsequence}}

Would there be a way to set this point as their respawn point without coding? Or should I just use the sequencer to call a method like "SavePoint = transform.position" and then player goes to "SavePoint" on deaths and loads?

And then do I just add Game Saver components to everything I want to save? Or active savers?
Basically, which tutorial would be best for me or can you point me in the right direction with a few steps and let me find my way from there.
User avatar
Tony Li
Posts: 21962
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving At Save Points

Post by Tony Li »

Hi,

The Dialogue System's save system uses slot numbers. When you save a game, you tell it to save the game under a slot number (e.g., 0, 1, 2, etc.). When you want to respawn/reload that saved game, you specify the same slot number.

1. Start by doing one of these two things:
  • Download and import the SaveSystemPrefabs package from the Dialogue System Extras page. Add the Save System prefab to your scene, and add the LoadingScreen scene to your project's build settings.
  • Or add these components to your Dialogue Manager GameObject: SaveSystem, JsonDataSerializer, PlayerPrefsSavedGameDataStorer. Optionally add a StandardSceneTransitionManager, although you can set this up later. (The Save System prefab in the SaveSystemPrefabs package is preconfigured with these components.)
2. Add a PositionSaver to your player GameObject. Set the Key to a unique value such as "playerPosition". Tick Use Player Spawnpoint.

3. Add an empty GameObject to your scene. Add a SaveSystemMethods component to it. Inspect your conversation's dialogue entry. In the OnExecute() UnityEvent section, add a scene event. Assign the empty GameObject, and configure the event to call SaveSystemMethods.SaveToSlot. Specify a slot number, such as 0.

When you want to respawn, use another SaveSystemMethods component and call SaveSystemMethods.LoadFromSlot, or in C# call PixelCrushers.SaveSystem.LoadFromSlot(0).
DrewThomasArt
Posts: 60
Joined: Thu Mar 24, 2022 12:07 am

Re: Saving At Save Points

Post by DrewThomasArt »

Thank you! It seems to be working perfectly, the player dies and spawns at the save point.
However, now whenever I change scenes or die, the Health Bar UI goes missing from the player's Inspector. It's odd because it wasn't happening before.
Is this possibly something to do with how the Save System starts new loads? I wanted to ask before I tried to just re-find the health bar UI on every load and death, because I'm not sure that's the best way
It's not like my player is getting destroyed when he dies, and when he changes scene the new player object should automatically have the Health Bar in it like it used to.
SS1 Working.png
SS1 Working.png (771.11 KiB) Viewed 626 times
SS2 Dying.png
SS2 Dying.png (695.84 KiB) Viewed 626 times
After being killed and Health Bar UI going missing:
SS3 GoesMissing.png
SS3 GoesMissing.png (779.24 KiB) Viewed 626 times
My code for dying and loading at Save Point:
SS4 DieCode.png
SS4 DieCode.png (362.83 KiB) Viewed 626 times
My code for loading new scenes with the Save System
SS5 NewSceneCode.png
SS5 NewSceneCode.png (327.11 KiB) Viewed 626 times
Thanks for any help.
User avatar
Tony Li
Posts: 21962
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving At Save Points

Post by Tony Li »

Hi,

I'm guessing it's along the same lines as the situation described here: How To: Manage Player Controls and Scene Changes
DrewThomasArt
Posts: 60
Joined: Thu Mar 24, 2022 12:07 am

Re: Saving At Save Points

Post by DrewThomasArt »

Nevermind, I think I got it.
I didn't know I could call the healthbar at the Start function instead of the Inspector and that seems to do the trick.

Now it seems to be working amazingly, thank you
User avatar
Tony Li
Posts: 21962
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving At Save Points

Post by Tony Li »

Great! Glad it's working.
Post Reply