Day 13 - *Easily* Saving Data Between Levels


Disclaimer

I'm a programmer, so most of these posts are just me nerding out about the tech that we develop, and even then I don't usually nerd out nearly as much as I'd like to.

SO FROM NOW ON, I'll start these posts with a little TL:DR, for people that just care about the game, and not the way that it works! For all my fellow nerds, keep scrolling for all the behind the scenes!


The relevant part of today's progress is that:

Now, the player can buy items on their Heist Hub to use on the Heists! Here's a quick showcase with the player buying some Throwing Knives:

Still gotta add the whole visual side of things, but at least the logic is working!


Nerd Talk

Okay, so *technically* I cheated a little bit. Today should be Day 14 since I did some light work over the weekend, but it was nothing special or interesting, trust me.

Basically, I hooked up the game-side of information retention to the file-side of information retention.

We're using a Scriptable Object Oriented approach to the save system, which means that while the game is running we use Scriptable Objects to keep track of data between scenes/levels. Once the player saves the game, all the info on the Scriptable Objects gets dumped into a file, and, once the game is booted up again, all of that data is loaded back into the Scriptable Objects again.

This should, not only, keep file access to a minimum, but also using scriptable objects allows you to have data that is very easily relayed to objects in your scene. No more Singleton shenanigans or having to read/write from a file whenever a scene is loaded. Especially useful for inventories and loadouts!

So, for today, specifically, I began connecting this to the actual game.

So now, how many knives the player has, for example, is handled by a specific Inventory Scriptable Object, instead of an Inventory Singleton. So, ANYTHING, that needs that data can read it directly from the SO!! No more worrying about scenes not working without an Inventory (or any data object) Game Object in the scene!! Woohoo!

All I had to do is give my Inventory SO to my shop script, and it just incremented a few values on the data, that's all it needed to do. No more, no less! Then, in the Game Scene, I can just read those values, without no middle-man code to transfer that data!!

I guess the only reason this is so cool to me is because how much I've suffered in the past because of crap like this, lol.

Anyway, that is all for today!

Phill

Leave a comment

Log in with itch.io to leave a comment.