How can i keep a variable referencing an actor after destroy?

So i am working on a inventory system.
The code i have set the “Pickable” item on the ground to an element array of “Pickable” class .
and then i destroy the object in the ground.
after destroying the object i lost the reference in the array element…

That array is my inventory.
How can i keep the object that i grab in the array but destroy it in the game world?

Well, you’re getting it wrong.

The reference in the array is of the actual object, when the object is destroyed the array now has a reference to nothing.

What you need instead is an array of a struct to copy over all the relevant data from the object you just picked.
Like, object type, stats, etc. Whatever you need.

But you absolutely can’t access an object after it’s been erased from existence.

Can I see the code you have for picking it up and destroying it

So in that case i can’t use the functions i have on the Item BP, right?
Like if i do that, imagine that when i touch the E Button i want to run some piece of code in Item BP, like Eat() , for example.
All codes should be moved to ThirdPerson Character BP?

it does destroy just doesn’t go into inventory correct?

right before you destroy it add it to your inventory and see if that takes care of it

yes thats true

it is already done in the player BP , when i set elem array

265274-setarr.png

which one is adding it can i see that code