Actor destroys automatically after setting hidden and disabling collision

Hello fellows,

I have a problem with my inventory system. First some information for what I want to do:

What I want to accomplish is to have a blueprint which holds all information for that “ingame-item”, including the StaticMesh, Title, Attributes and so on.
Now also I want to be able to pickup and drop the item. This leads me to the idea to disabling collision and set it hidden when I pick it up. Then I can switch this back when I want to drop the item again.

As far as I am I can grab the item and could also drop it. but here I have the problem:
After I disable the collision and set the item to “hidden” when grabbing it, it takes like 2 seconds and the Actor disappears from the “Scene Outliner”. So I can´t drop the item anymore. My guess is that my Actor got destroyed within the period between picking up and trying to drop the item.

Here is the BP which hides the item:

A short time after that I am able to drop the item again. If I wait to long tho, I am not able anymore.

Do someone have an idea why this is happening and how I can avoid it? :slight_smile:

So, I managed to get it working using this instead of the one mentioned in the question:

Now I´m using my collision disabling and hide on the static mesh, instead on the whole Actor. This avoids the removing of the Actor from the Scene after some time.
Is this some kind of bug or just wrong use of BP from my side?

Great question and thanks for the answer below. It would be nice if someone could explain why your first approach didn’t work. Are we not supposed to set actors as hidden and disable collisions? Why does that cause actor destructon. Anyone info from folks at Epic on how this should work would be great.

1 Like

Thanks for the comment. By the way, I’ve never used delegates with blueprints. Do you have a good pointer for learning how to do that?


Yea, I think I was having a related issue earlier today in my game. I was disabling collision on my character’s capsule component and the engine would just randomly destroy my actor and trigger the OnDestroyed delegate I had setup. I would love to know why the engine thinks its a good idea to randomly nuke your character out of the blue. If I hadn’t just happen to have an old breakpoint on the OnDestroyed delegate I don’t know how I would have ever figured out what was going on.

Well here is a pretty simple example of setting one up the one I was using:

That makes perfect sense, you’d have to disable physics to prevent that from happening

Gravity will still be applied to your actor, despite collision being disabled. The fact that collision is disabled is ironically what causes it to be cleared up. It no longer collides with the floor so it begins to fall. Actors below a certain Z height are automatically cleaned up.

In addition to disabling collision and visibility you’ll need to call SetSimulatePhysics( false ) on any mesh components on the actor.

Can’t you just create a container class that is a container for item(s) that are picked up and placed in inventory? Then all those calls to disable collision, physics, and hide can flow from the event of adding item to container class. Dropping item(s) switches it (perhaps add a static switch or bool), and changes those hide/physics settings back to item(s) interacting with game world as initially intended (when not in inventory).