I appear to be dealing with Schrodinger's Variable

I have a non-local Map Int+Struct variable I set at Event Begin Play on an Actor Component attached to the Game Mode which keeps randomly getting deleting immediately after I set it, but most of the time it doesn’t get deleted. It appears to be random whether it’s deleted or not even though I don’t have anything that should delete or even modify it beyond the initial set-up.

I piggybacked off an earlier timer I made on 0.1 seconds repeating loop to print a field from the Map Int+Struct:

It keeps printing the field even after the variable has been deleted:

So does anyone have any ideas why it’s getting deleted? I think I might know why the detection method used failed, but I am writing this way too late in the morning and am in desperate need of sleep.

1 Like

I’ve seen various posts about blueprints losing fields in structures, when they are part of another type. But no real answers.

I didn’t notice this today, I don’t know if it’s any use…

The specific problem I’m having is with both default value loss and instance value serialization, I didn’t mention this previously in the post because I decided on a work around that’s working (for now), but the exact Struct I’ve been using has been getting it’s default value wiped as well. I figured it had to have had something to do with the fact that my Structs are 5 layers deep, but looking back there are several instances of exactly these problems happening even when the layers weren’t as deep.

This looks like something I’m going to need a few days to fully digest, but this is the problem I’m experiencing. Interestingly, the problem doesn’t occur if the default values I reference in the editor still read as they are supposed to so long as I don’t serialize any instances. It happens the most when I have a Struct in a Struct though; through testing I found that undefined Structs within a Struct can result in the whole larger Struct failing to serialize entirely which is most likely the problem I’m having now.

I don’t really know if I should mark your comment as the “answer” since now I know it’s basically just a bug with Unreal itself and that I need to focus on methods that better report when this bug occurs and focus on methods that don’t mess with the memory so much, but it will probably help the next poor scripter too who doesn’t know what’s happening so I will. I could be wrong in thinking this “solves” my problem completely, but with this I’ll be much better informed on what specifically is happening.

Thanks for giving me the tutorial; I went ahead and bookmarked it since it’s quite a lot of information and sadly most of it appears to be relevant to my issues.

1 Like

I don’t think it’s subjective, this seems to have gotten significantly worse since 5.

Not being able to rely on basic structure is a little disheartening… :melting_face:

1 Like