TArray Elements mysteriously dissapearing?

I’m working on a C++ driven inventory system, and i’ve made a class called pickup. The inventory is represented like so:

    TArray<APickup*> MyInventory;

I can pick up items and they get added to the inventory array, but after around a minute they mysteriously dissapear from the array. Does anyone know why this might be happening?

I have a method that removes items from the inventory, but I commented this out just to ensure that wasn’t the problem, and the problem is still occuring even after commenting it out.

A guess: this is a replicated array and you are modifying it on the client. That would result in a temporary value, which is overwritten once the server value is replicated. Other reason could be (if the length of the array is still > 0) that the pickup actors themselves have been cleaned up.

Thanks for the suggestions :slight_smile: I would bet that it is the second one. Any idea on how I can prevent my pickup actors from being cleaned up? I obviously want to keep them in my inventory until the player uses them.