4.20.2 - Unable to Destroy Actor From Pointer

Hello,

I am currently in the process of updating a few of my plugins to 4.20 and I’ve almost everything working fine, except for this one weird issue. To give a summary of what I’m trying to do, basically, in my VR app, I have an actor that spawns as a preview of where the player will teleport. It is created when the motion controller track pad is pressed and should be destroyed on release.

The creation part works fine, and the event for the button release is working as the log macro is printing to the output log. Below is the function implementation:

void AGenericMotionController::DeactivateTeleport()
{
	if (TeleportPreview)
	{
		UE_LOG(LogTemp, Warning, TEXT("I would like to destroy %s"), *TeleportPreview->GetName());
		TeleportPreview->SetActorHiddenInGame(true);
		TeleportPreview->Destroy();
		TeleportPreview = nullptr;
	}

	bTeleportActive = false;
	ClearArc();
	
}

And the method definitely runs, as I get the log message:

252048-ue4editor-2018-08-30-11-54-12.png

However, the actor remains rendered in the scene, even through it appears to have been removed from the world outliner. I’ve posted the entire editor in the screenshot so that you can see that there is not actor in the outline named BP_TeleportPreviewActor, but the mesh remains in the scene despite this.

When I eject from the pawn, I can click on the mesh and it populates the details pane:

If I run destroy from the preview actors tick, begin play or the motion controller’s tick, it is destroyed normally including the mesh, but if it is called from the handler for the release event, it simply does not work. I even tried making a blueprint implementable event that would be called on the blueprint actor, but again, it runs the log I places in the event handler (this time on the blueprint side) and does not destroy the actor.

Something even weirder is that if I move the actor after pressing the button again, the previous one appears to have been destroyed.

I’m definitely scratching my head on this one, and if anyone has any idea of where I can go next, I would greatly appreciate it. Thank you in advance!

…if anyone has any idea…

Idea - yea, solution - not really.

Something might be preventing the Garbage Collector from destroying the Actor…

Try calling an internal Actor function - I wonder if it will produce a warning that the actor is marked for deletion.

Why it affects only the handler for the release event but not all other cases - I have no clue.

Try unbinding all events(if any) from the Actor before deleting it…

Thanks for you suggestions. I did try having the preview actor print a message on tick, and it just keeps on ticking. I’m going to keep my code in 4.19 for now, but If I figure it out, I’ll be sure to post it.