Are you happy with your save system?

Is it working well? Do you feel able to extend it for new state you add to your game?

1 Like

I’m super happy with it! Really enjoyed this section as it’s something I’d never been able to understand how best to achieve before.

One change I’m planning on making is setting a version number so that my load can work on different versions as needed. Save can always just save as the latest version.

2 Likes

Thank you Sam for teach this awesome method for saving in Unity, it’s really interesting and very usefull, little complex but after 2 time I seen it I’ve learn better :slight_smile:

1 Like

Could I download the full project somewhere? Because On github are only some folders but when I replace my folders in my project with the github folders it gives a lot of errors and missing things?

The full project is on GitHub. Try downloading the zip and just opening the folder in unity.

I tried but it’s giving a lot of errors, I also tried opening it with different versions of unity but still full of errors

Might need more information to help you. If you use the right version of Unity it should work.

I’m using the version 2018.3.3 like in the video, most of the errors are about the cinematics

I was pretty terrified of this section going into it, since the only term I knew was “binary”. It was laid out and paced really well, so now I’ve been able to go back and make additional data saved. I’d also feel comfortable being able to transfer the whole system to another game or project and have it work pretty seamlessly.

One bug I ran into and don’t know how to fix elegantly is the following:

If you kill an enemy and reload, the animation can’t transition out of death, so the enemy just stays on the ground with the navmesh disabled. I was thinking of changing the animation from a trigger to a bool and then allowing a transition to Any State if the bool is set to false. Then in the RestoreState method, add an else statement to kick it out of the death state.

1 Like

Easiest solution here is to reload the level. That way you know what state you are starting from when restoring.

Reloading the level works, but I wasn’t able to build logic in the existing methods that would work in all situations. I ended up making a “ManualLoad” method in the SavingWrapper that calls the LoadLastScene IEnumerator and then commented out the check for whether it’s the same scene. Seems like it’ll work for now since the scene loading is pretty much instant.

Would a good option be to load the save file, set the lastSceneBuildIndex to 0, then call the LoadLastScene IEnumator? The main issue with that solution is it’d require making LoadFile public rather than private.

This is what I ended up doing when I first made the death sequence because I was thinking about resurrection spells/items. You can’t transition back to Any State though. I just went straight to locomotion, but you could do entry.

If you don’t want to use a bool, you could make another trigger called revive.

PS Great job on this section Sam. Love the use of Interfaces. I like the way you kept everything together at first, then showed the process of separating it out as it got more complicated.

I wouldn’t bother with trying to reuse LoadLastScene. Just copy it and call it ReloadScene and modify away. If you find the code get duplicated in a 3rd place then think about factoring out the common bits.

I made some tweaks as I went along, although I have found that some of them were things you ended up putting in later (like I put the save command in when switching levels to avoid the bug of it loading the player into the portal when the level starts). I was actually more worried that the WebGL version would have issues using this saving system and that I would have to implement a separate saving system to do web saving. I am happy to report that this system of saving does work with a WebGL published app.

I feel like I will have an easy time expanding this, the next thing to do for me is to keep the cutscenes state so they don’t all reset to untriggered every time the player reenters the level.

1 Like

Did I miss the slide where we added the Delete functionality for the save file? I finished section 9, then went back to watch section 8, and 8 shows the delete function existing. It was easy and quick, so I added it in myself, but I don’t think I missed it being added in section 9. I opened the github commit for the last couple commits in 9, and don’t see it there either. Are there any other little things we should add to the saving system to have the same functionality as importing the premade one?

No, it gets added later in the course. I didn’t have the premade one when I built the course so you should be fine following through.

Does the save system work with unity 2019.1

Yes, I’ve imported it into 2019.1 with no issues.

In my scene I have a moment where the player can pick up a health potion and the object is deleted. When i leave the scene I am getting the save message in the console but when i re enter the scene the potion returns. How do i add the save system to a object I want to delete so it does not respawn when I go back to the scene. In other words delete it forever., and have the system remember it is gone.

Hello, i made a discussion thread about how I extended the saving system to also capture the state of objects that are spawned or get destroyed during runtime.
you can have a look at it here.

Privacy & Terms