Save game stop working when using level streaming?

Does anyone know why this happens?

we’d need a lot more info but to guess, when you stream levels the old world/actors may still exist so things like BeginPlay may not be called

Well okay so how my save system works is that when a collectable is picked up it gets added to an array and saves and in the save game there is a function to destroy the items in the array which is loaded from the gamemode on begin play. also all my collectables are in a persistent level so no collectable get deloaded which is why im confused.

i’d start debugging by checking your references, put a breakpoint on your save/load events or check things like is the gamemode valid, is the collectable valid etc with a printstring

I have debugged the collectable to see if its valid which is how i discovered that level streaming messes up my save game but it only messes up the new things that are collected so old collectables will stay destroyed but not new ones which is why i don’t think its a problem with the gamemode. I know what causes it i just don’t know why it causes it and how to fix it.

I have tried now moving the saving functions into the game instance no luck this is such a odd thing.

it sounds like theyre not getting saved to the array?

How would i debug that too see if they are or arent?

Actually i was wrong i think it messes up old things that were collected meaning for some reason going into a level streaming bounds then leaving and picking up a collectable i guess breaks the old one

ah so you could be reseting the array, or its not saved.

where is the array and when you add/remove something to it thats where you can debug it

Well the array is in the save game file and the thing gets saved inside the collectable it saves it there before its destroyed. I am pretty sure though that the it is writing but again going into streaming bounds i guess corrupts it

I figured it out. All I had to do was change the way levels load. rather then using level streaming volume it instead uses a load level streaming node.

nope actually didnt work dammit

This is so stupid why does this happen and only happen with an array of actors it doesnt happen with like names.

Are you trying to save the array of actors?

Can you share the blueprint?

Its abit messy but this is how my collected item is being added to the array in save game. and this is about it there isnt much more code for this atleast related to the array

Think that is the problem right there: you are saving references to actors, meaning their memory addresses for a specific instance. After the actors are destroyed, those addresses are no longer valid.

What you should do instead is assign an ID (int, FName, FString, enum, etc) to each item and save that ID in a list or container of your choice. On BeginPlay, each actor should check whether its ID exists in that list. If it does, it means the item was already collected in a previous instance and should be destroyed.

You can manually assign the ID and keep track of them in your GDD, or have a system generate and manage it for you.

2 Likes

You got any idea on how i would do that in a unreal you know to check if the collectables id is valid and to destroy it?

Sorry for late response.

Try this:

It’s important to limit all interactions with the save game through the interface. If something does not work then you’ll only have one place to check.

  • For the item, you can place this in the item class or in a component:


With this, because save game object is in game instance, it will persist for the duration of the aplication and all items will check at their respective begin play.

This should be extended so that the collectible items listen to when a load happens or to be sure that they only check after sve game is ready (don’t use timers or delays for this, always go the event driven route). But first try this and let us know if your issue is solved. All are welcome to share if they have any suggestion or better way to do it in BP.

1 Like

this did help quite abit only one problem. for some reason it doesnt work in a packaged build.