How to get a copy of self ?

Hi, just a quick question but how do i get a copy of self instead of using a reference because when i destroy the actor principal weapon set to none (principal weapon is a variable from my player not from the actual blueprint)

Think your issue is probably a misunderstanding of what a “copy” is in Blueprints.

If you store an actor in a variable, that variable only holds a reference, meaning an address to the object in memory. Making another variable or “copying” it does not duplicate the actor itself, it only copies the reference. Both still point to the same actor.

So once that actor is destroyed, the reference becomes invalid, and trying to access it will give you an “Accessed None” error.

yes my question is how to keep the actor in the variable when this actor is destroy in the scene

Hey there @Xernesser! Welcome back to the community! So that then depends exactly what you mean by “Keep the actor” as a copy.

If you mean keep a variable that references that class and leaves a reference for one but doesn’t require one to be in memory beforehand (or after), a Soft Reference would probably be ideal but doesn’t retain any data besides a place for it.

If you instead want a “copy” in the sense that you retain all data that was attached/configured on an actor before it was destroyed, you’ll probably instead want to save the important bits as a struct and decide if you want it session wise storage (GameInstance) or retained between sessions (Saved) then apply it back to the actor when created again.

Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.

You can’t.

It is dangerous to keep a reference to a destroyed actor so there are number of measures taken to make that almost impossible. It is also no real scenario where that would be useful.

Disable and/or hide the actor instead of destroying it.