C++ How do I release references?

I am
Setting the define of an actor on spawning. When it spawns is sets a reference to itself to controllers in the area.

How do I set its reference to null in the controllers? Do I do that in a destructor? Is there something else that is called when setlifetime() s time is up? Is there a way to set a weak pointer that will clean itself?

Right now the pointer is still left after the object is gone, it’s not null but is not valid but I don’t k ow how I should be testing it.

The reference will be set to NULL eventually, when Garbage Collection runs. You can find out if it is awaiting collection by using IsPendingKill. We also have a TWeakObjectPtr you can use, which makes this a bit cleaner, but will not prevent non-Actors from being garbage collected. It’s a good thing to use for an ‘observer’, which it sounds like is your case.