Destroy Actor doesn't work for BP classes derived from C++ base

Hi All,

I’m having a c++ ItemBase(subclass of AActor) class from which all my blueprint item classes derive and they also implement an Interactable interface having only the Interact method. In my playerCharacter on press of a certain key I am looping through all the overlapping actors and if an actor implements the interface, the Interact event is fired. In one of the item subclasses (BP_Sphere) I implement the Interact event and call DestroyActor. When I put the player within the SphereCollider of the item and hit the key, the node breakpoint is certainly being hit and if anything is beyond that, that is also being executed, however the actor is not being destroyed from the scene. But if I use the same ItemBase as a blueprint base class instead of c++, it works fine. Am I missing something ?

Here is the c++ itemBase class:

and here’s the BP_Sphere:

If you put a print string between the “Event Interact” and “Destroy Actor”, does it print?

There is nothing wrong with the code. You must be doing something that is preventing the destruction. Are you storing some references or something?

Yes it does, it also prints if it is after the Destroy Actor. I tried checking with breakpoints also, all the nodes execute perfectly and no error is logged.

Just stumbled across your thread having the same problem and found a fix for it.

For anyone having the same problem make sure to call Super::BeginPlay() if not it will prevent the destruction of the object. Not sure why but its always good to include this and this fixed it for me.

2 Likes

Lifesaver. I already started to panic, but it was such an easy fix.

Try pulling out a Ref to Self from the target.

you, sir, just saved me.