Attaching and detaching actor on character


What is a good way to attach a physics object to an ai character but also be able to detach it?

In my player Bp i can pick up physics objects and in my ai character Bp i have a trigger that when ovelaps with the physics object attaches a mesh to the character.

But what is a good way of picking up the object again and detaching it from the ai?

To clarify, the question is how can I detach an actor from a character, I can attach it fine but not detach it

Found this thread that explains how it was done, despite he’s mentioning there’s a problem with that, this might not have to do with what you want = ]

*"So basically i disable Simulate Physics (in case it was set), so it doesent fall out of our hand. Disable collision so it doesent keep colliding and then call AttachActorToComponent to put it into our socket.

When i wanna drop the item, i DetachActorFromActor, Renable Collision and Physics. "*

I got it to work by making the attachment logic in the object bp and casting it to the character, the detachment was was made in my player bp where I simply checked if I hit the object I attached and set it to simulate physics.

I’m a happy camper :slight_smile:

So, 4 years later, I found this because I’m having trouble with this behavior. I do it this way, and it attaches and detaches fine. The first time. It seems like once it detaches, i cant get it to reattach. My toggle fires correctly and collision and physics are disabled and re enabled correctly, but the attach actor to component just will not seem to work more than once, its odd.
While I’m waiting on a response, I’m gonna try a different approach and handle all this attaching and detaching behavior from the pawn instead of the pickup actor from the pawn and see if that goes more smoothly.

Ok. I applied some scientific method and I fixed it! So my static mesh is actually a component of an Actor, I’m doing it this way cause in the future ill need these pickup items to have variables so they can be used for gameplay. What I discovered is when you simulate physics on a static mesh COMPONENT inside an Actor blueprint, it somewhat ignores the world transform of the default scene root in order to do all its physics stuff. The actor never moves, but the static mesh component does move in world space when simulating, whenever i tried to attach the actor again after dropping it, the actor actually was reattaching, but because i had enabled physics on that static mesh component, it never followed it’s parent actor that was being attached to the character. So in this case it is not enough to stop simulating physics on the static mesh component. You also have to reattach the static mesh component to the default scene root of the Actor that it lives in, and THEN you can attach the Actor to your character, then it will follow the character properly.