I’ve finally narrowed down this bizarre issue to a cause, but now i have no idea how to fix it.
Around 50-60 seconds into runtime, my Backpack and Equipped arrays, which are both full of PickupParent actors, clear all the data of the actors they contain. I know this because testing the length of the array never changes, but if I print the display name of Backpack[0] every frame, eventually it just disappears, signaling that the clearing has happened.
Whether I stand perfectly still or not, or press any inputs, this always happens around 50-60 seconds. What is going on?
There’s two nearly identical execution chains here, only difference is that the top one adds to Equipped weapons and bottom adds to Backpack items. Both arrays get cleared at the same time.
It’s never set anywhere (using defaults), so the only time I can see where it would be changed is the Adds for the two arrays. Is there a better way to add content to an array within a structure?
Interesting, it might be. Only issue I see with this is that I don’t re add the Closest Pickup multiple times. Why would the arrays clear themselves after a period of time if they were working perfectly before? I’ll go add some isValids before the Closest Pickup gets added where needed and see if anything changes
the 8 slots below “EQUIPPED” show up regardless.
the “misc” section on the right is for stuff that doesn’t fit anywhere else
so just to reiterate, they lose all their data and just go into the Misc section because they don’t have any other classification. It seems like they’ve reverted to just a default Object, but I’ll test that in a second. unfortunately, adding more isvalid checks to the ClosestPickup adding did not fix it.
Thanks, that gives more insight.
I just did another test, the only way I’ve been able to reproduce anything close so far is by linking in the Destroy in the code below:
Sorry for the late reply, the website has limited my commenting.
After testing what class the items get switched to, I found that its literally an invalid value. As in, their class is just entirely removed? ???
(in response to your last message) What kind of errors does this generate? I don’t see anything that would cause inValidity or surprise removal… but maybe that’s what I’m missing in my project too
Also, I don’t believe any of the other values in the Player Data struct are being altered in any way
If there’s an alternate way to add items to an array within a struct, I want to try that but I can’t think of anything
To test your arrays are ok, you could try adding an array of strings to your PlayerData Struct, then at the same time as you add the reference to the Closest Pickup, add it’s name like: