Permanently Destroying Actor

Hello All,

I have been trying to figure this out for a while: there are many pickups in each level of the game I’m making. Once these are picked-up, I don’t want them to respawn again on the next play through. Once they have been picked up, they are gone for that save. I have been pondering a few different things to try, not sure if these are the proper way to go though. I was thinking of adding a bool to the actor, and if it gets checked, the item won’t respawn anymore. Easy enough, but I’m trying to think of how to save that data. Write it out to a file? Then each level would need it’s own file, lot of extra baggage. Should I try to write all of this to the save file, and try to figure out some way to parse all the data to determine whether and actor should be spawned or not? Seems like that would cost a lot of overhead. Am I making this more complicated than it needs to be? There has to be an easier way of doing it. I also don’t mind doing it in C++ or BP, just figured it would be easier to do in BP than C++, but that also brings up the extra overhead of doing something like this in BP. Anyways, if you anybody has a little light to shed on this, that would be greatly appreciated. Thank you for your time.

Hello,
Personnaly i would set an int value for each pick up and use a bool array with this value as index. When an item is picked up value is set false. Array is added to save file and on load it is looped to spawn or not. One array for all or one by type of pick ups, depending of number of pick-ups.

I was thinking that also. One problem I had with that was figuring out when to stop placing the pickups in a level if all that data is stored in the save. Currently, I have the pickups placed in the editor. I was thinking that I would have to change that to spawning at level start to be able to determine if the pickup should be there or not. But if I change that to spawning, there is going to be a lot of data in the save. Probably the only way it’s going to work though. Trying to think of a way to place them in the editor so I can do it visually, then just make them not load on the next play through.

If you want reduce amount of infos you maybe can do random places of spawn and save number of pick ups by type only. A percentage of used instead of exact set up but it would be a really small array to save load.

I am not able to place them randomly unfortunately, they need to be placed in certain places around the level, that is why I’m wanting to use the editor to visually put them where they need to be. There is only 2 types of pickups, and one of them is not going to be used a lot, but the other one is going to be put all over the levels.

Ok :frowning: Sadly i don’t see a way to save infos better than save in an array when leave and load it / use it on next level play.

Thank you for your help. I can’t think of doing any other way either at the moment, so that is probably the route I’m going to have to go. Thank you very much again!

I did a tutorial/video a while ago in regards to save data. In the video I showed a set up for doors to set the open/close state when the level is loaded. The set up used the doors location to save the data so they can easily be added to the level (once the setup is done) and have it track its state. Check out my blog (voxagon) for the video, it should help you. :slight_smile: (currently at work so cant get the link)

Location is a cool idea ^^ Maybe a bit higher array than bool but no need to set a variable. Thanks for sharing.

This is exactly what I was looking for. Thank you @pattym and @Fen for all your guys help. You guys are awesome.

Ok, sorry guys, I came across another problem. I followed @pattym tutorial all the way through, but I ran into a problem. The first time I play the game, all is as it should be. But the actors that I added this to destroy on the next load up. If I only destroy one actor in the game, all actors of the same class are destroyed on the next play through. For instance, if I had used this for your door tutorial, and only opened one door, all doors would be open on the next play through. I’ve added a screenshot of the section of blueprint that this is happening in:


The branch at the end with the destroy actor is what is getting rid of all of them. But with the way things are setup, it should only be destroyed if it is picked up, the bool is set to false then saved, and then saved. So on the next load up, all the actors that did not get picked up should still be true and not get destroyed. This even happens if I don’t pick anything up. I’m lost, thank you for your time.

First thing, i wonder is about pick up active ref size. If for some reason it is not right sized, it may be being one entry rewrited only so you need to set its size at start by a loop based on pickup ref array size ( or maybe only check “size to fit” but not sure it will be enough but as it is a click / compile / save / see this is easy to try).
Second thing i wonder is where is “is active” from as i don’t see it on left. If this is not the array, it may be this variable not reseted and considered once for all elements.

Thank you very much, Size To Fit did the trick, didn’t think to expand the array, doh! Thank you again.