Inquiry // Advice on saving large amounts of GameObjects

Discussion and help for Easy Save 3
Post Reply
SomeHumbleOnion
Posts: 5
Joined: Sat Mar 05, 2022 8:34 pm

Inquiry // Advice on saving large amounts of GameObjects

Post by SomeHumbleOnion »

Hello everyone!

I'm currently trying to save the state of coins that are scattered around my level, that way when the player loads a save, the coins they collected are no longer there. These coins are prefabs and there are hundreds of them scattered around the level.

What would be the best approach to go for with saving this? At the start of my game I simply want to disable them if they've already been "collected"

Right now my current approach is this:
- Created a list of gameobjects that represent the coins you've collected
- Each time a coin is collected, I add it's game object to the list. The list is then saved whenever the player saves the game.
- I've added every coin prefab in the scene to the "References" list of the ES3 Reference Mgr
- Upon loading the game, I load the list and loop through it. Each game object in the list is deactivated.

I'm having some issues with this approach however.

For starters, I'm getting warnings of "Reference with ID... could not be found in Easy Save's reference manager" which is strange because I've added each individual coin prefab to the references list.

Also, each coin has a handful of components and child objects. It seems these are being saved as well and it's created these massive entries in my
list of collected coins when I really just want to save the parent object reference so I can deactivate it at the start of the game.

My apologies if this questions is very noobish! I've been using Easy Save for a few weeks now to save smaller things and it's been incredibly helpful! But I've been stuck on this for a bit as I'm trying to approach it in the cleanest way. Thank you!
SomeHumbleOnion
Posts: 5
Joined: Sat Mar 05, 2022 8:34 pm

Re: Inquiry // Advice on saving large amounts of GameObjects

Post by SomeHumbleOnion »

So I think I've come up with a better solution, but I'm still getting Refence warnings.

What I've decided to do instead is save a list of CoinCollected scripts. When a coin is collected I set a boolean isCollected to true and add the script reference to the list which gets saved by easy save. Then at the start of the game I loop through that list and if any show isCollected as true I disabled the assoicated GameObject.

So far this is working in game, but I'm still getting warnings that "reference with ID xxxx could not be found in the Easy Save's reference manager" even though I've added the coin object to the ES3 Reference Mgr. Any ideas why I'm still getting this error?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Inquiry // Advice on saving large amounts of GameObjects

Post by Joel »

Hi there,

Just to check, have you followed the instructions here?

https://docs.moodkie.com/easy-save-3/es ... s-prefabs/

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
SomeHumbleOnion
Posts: 5
Joined: Sat Mar 05, 2022 8:34 pm

Re: Inquiry // Advice on saving large amounts of GameObjects

Post by SomeHumbleOnion »

Hey Joel!

My apologies for such a late reply to this.

I have indeed followed the instructions on the easy save docs, however I'm still a bit confused on what's happening. As mentioned earlier, I'm trying to save references to these scripts that are attached to each collectable rock in my game. I've been calling them coins since the terminology is easier, but they're actually these little collectable rocks in game. That way at the start of the game, I can check if they've been collected already from a save file and deactivate them from the scene. These rocks are indeed prefab instances in my scene.

I've added all the rock prefab instances to the ES3 Reference Mgr and I also tried added a reference to the prefab in the ES3Prefabs area after enabling the 'Easy Save For Prefabs' but still not luck.

I've pasted the link to a video showing what I'm seeing in the reference mgr when I run the game. When the game runs I collect a rock and then press save which saves the script reference. However, shouldn't that reference already exist in the manager when I added the prefab reference to the Reference List? What's strange is I can load this save and it will still work, as in it will disable that rock that was collected since it still saved the reference successfully, but I'll get warnings about how the reference ID could not be found in the manager still.

I look forward to hearing your reply and my apologies if this is something very simple that I'm missing.
Attachments
test es3.gif
test es3.gif (33.33 KiB) Viewed 981 times
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Inquiry // Advice on saving large amounts of GameObjects

Post by Joel »

Hi there,

Just to clarify, are you only trying to save whether each of these is objects is active or not?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
SomeHumbleOnion
Posts: 5
Joined: Sat Mar 05, 2022 8:34 pm

Re: Inquiry // Advice on saving large amounts of GameObjects

Post by SomeHumbleOnion »

That is correct yes! That way if they've been collected (which sets them as deactive) I can save that and when you load the save file they'll remain deactive.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Inquiry // Advice on saving large amounts of GameObjects

Post by Joel »

Hi there,

In this case saving the entire GameObject isn't necessary. I've attached a script which you can attach to a GameObject to store it's active state.

All the best,
Joel
Attachments
SaveActive.cs
(693 Bytes) Downloaded 74 times
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
SomeHumbleOnion
Posts: 5
Joined: Sat Mar 05, 2022 8:34 pm

Re: Inquiry // Advice on saving large amounts of GameObjects

Post by SomeHumbleOnion »

Thank you so much for this!! I really appreciate it :D
Post Reply