Soft object references???

I have finally created a functioning save system that makes it so items picked up in one map do not show back up if you ever return to that map. The problem is that they seem to be popping back up. I don’t know if there’s a time limit or what but the actor gets destroyed it gets saved and it’s gone for a while. I’ve noticed that it seems like after I save a second time, the things that disappeared during the first save come back. I have seen some mention that I should store all of the destroyed actors as soft references in my array. Unfortunately I have no idea how to do that. Does anybody else have any experience with this that can help me understand creating soft references? Just an FYI my entire game is in Blueprint and I’m not great with C++. I have watched a couple tutorials on hard and soft references and it doesn’t really seem to speak to what I’m trying to do.

Hey - me again! :disguised_face:

You don’t need to worry about soft refs, that just sounds like a bug in your save system ( sorry to say :melting_face: )

Can you show your save and load code?

1 Like

Always happy to hear from you! So here’s the breakdown. I followed a video (probably one your familiar with) to get here.

  1. All of my save functions are in my Game Mode. here is the top level event graph. F(x)s (functions) and vars on the left (“construction script” is empty):

a. Initialize level save data F(x):

b. Save level data F(x):

c. Initialize player save data F(x):

d. Save Player Data F(x):

  1. Saves are triggered by a click event in menu, and when walking through any door to begin a dungeon (these next two are a mess I haven’t cleaned them up much):

  1. Everything is loaded in the Character BP (Where all the variables live) at begin play:

  1. Each object referenced by the level save has this line of blueprint added to it to identify it as a collected object. (its just that top part coming off of the cast:

  1. There are two separate blueprints for level data objects and player save data. BP_LevelDataObject contains one actor array var. used in a F(x). There is nothing in the event graph.

a. BP_PlayerSaveData is just the list of vars that i save and load. no other BP logic in here as it is referenced by the player save object:

Im sorry. i know that is a lot. but i appreciate any help as usual!!

Ok, immediately, I see why the player location stuff isn’t working. Your player save is not level dependent.

Maybe you got that jumbled up. I’m assuming under this regime, that even though it’s a player quality, the player location is a level variable…

Gonna read further, because it’s a slightly insanely complicated system… :wink:

Other things I notice are

Cast FIRST. Then do the rest of this.

Destroy actor does… wait for it, destroy the actor. How can you expect to run the rest of this? :smiley: You might, by chance. Much better to put ‘destroy actor’ on the end of the chain.

Apart from that, it looks pretty logical.

I’d try those changes, then come back if it’s still doing something strange.

haha no way! destroy actor destroys it? :joy: no i get it tho! i have been having some issues with things not working right and you pointing that out helped with some other issues i was having (code executing after destroy actor nodes). so that does help! unfortunately, it looks like that isn’t the answer to my saving issue. i tried to toggle visibility instead but that is also posing problems of its own. another thing i did after putting cast fist in the save portion of things is i went back and checked all my actors with a cast to make sure the cast is at the front. im still in the same place but my code is probably a lot less buggy thanks to you.

1 Like

Which save issue remains?

  1. The player location ( which I think will be sorted once you move that part into the level based save )

  2. Collected items magically reappearing

At the moment, I’m not concerned with the location of the player (except the player start/possess issue from the other thread - thats a different issue). I figure i can probably address saving the player location once i get the level objects and begin play variables figured out. so the issue that is still sticking around is the destroyed actors reappearing.

Can you show the code for the bits you changed?

Do not store references in save games, i.e collected pickups.

1 Like

Hi there,

you want to save the level state so every interacted/ destroyed actor won’t reappear.

Look for an official tutorial with sample project called runtime saving and loading with blueprints in the learning section.

hope that helps.

1 Like

okay found it and working through it. thank you!

2 Likes

the only things i changed was moving the play cast to the front and the destroy actor to the very end. im gonna work through this unreal course and see if it can give me anymore insight.

1 Like

I’ve given up telling people not to use references. It seems that it does work in the editor, but I suspect not in a packaged game?

2 Likes

A reference is a memory address.

There is no guarantee whatsoever that whatever there is at the memory address is going to be the same thing from one session to the next let alone from one device to another.

2 Likes

I think what ends up in the SG, is the path you get when you use a print string on the level actor.

Blueprints likely implement references a bit differently than how C++ does it.

Regardless, they too, are tied to a specific object instance, and I very much doubt they’d store the entire state of the object into the save game.

1 Like

It does work, curiously. Because the object instance name is the same between runs. But I agree, it’s very unreliable.

Im still working through this tutorial. So far, it seems like my variables are saving between levels and when i restart the games. I haven gotten to saving objects yet, but based on what you guys are saying, is it kinda hopeless since im using blueprint? Or do you think following this project tutorial that @L.F.A shared will work?

Also, real quick, it seems that i can never start a game that is saved with full health full magic because the save game is always going to load in the last save variable values. No matter how i look at it, i can figure out a way to get past begin play. If i set the values to full at begin play, every map, cave, dungeon i go into thats a new map is going to use begin play and refill the values.

Also just a quick thanks to everyone on this thread especially @ClockworkOcean - i wish there was a way to pay you back for all your support i really do

1 Like