The easiest way to delete objects is to simply set all references to the object to “None” (null.)
The Unreal garbage collector will take care of the rest.
If you positively need to “destroy” the object right now, AND you know there are no other references to it, you can call ConditionalBeginDestroy()
, but it’s really neither necessary nor usually a good idea.
Edit: If your object is an AActor
there is also AActor::Destroy()
to start the shut-down of the object, and send its destruction on the network if it’s replicating.
Can the set by-ref var blueprint node set a uobject to null? The destructor of the uobject does not respond.
UObject
s are not destroyed when they are first set to null; they go in a queue, which gets gabage collected after there are no references to the object.
If you need to do something explicitly at a given time, you need a method on the object to do that, and need to call that method. UWorld::DestroyActor()
is an example of one such function, specifically for AActor
objects.