The actor component is removed with the actor

I need to add an actor component to the array. This component is in the actor. If I add a component to the array and then destroy the actor, the component becomes invalid after a while. I assume its to clean the garbage collector.
How can you keep a component from being destroyed?

Short answer is dont make it a component but make it a separate actor attached to the one that gets destroyed.

Another option is in the Destroyed event of the main actor, spawn a separate actor with the same properties copied into ut from the component and then let the component be destroyed along with its parent actor. The newly spawned actor that is identical to it will continue to live.

But it sounds like you want to keep a reference to something after it stops existing. That’s fine but it will not be a valid reference because the actor or component doesnt exist anymore.

So it might be better to create a strict or an Object class to store the propertues of the object in, and keep THAT in your array instead so that in Order to bring it back into existence you can just spawn it again and copy its info from that Object.