Attach actor to component, returns true, but actor stays unchanged

Hello! I have been raking my brain since yesterday about this. I have even tried creating a new project but the attach to actor function still doesn’t seem to work (surely some sort of simple minor thing that I am missing). I basically need the player to be able to pick up an object and then place it somewhere, and it seems like Attach actor to component function is exactly what I would need for that, but no matter what it just doesn’t seem to do anything to the actor I’m trying to attach, added a print string afterwards and it returns attachment as true (and yes I have tried changing all the enums in the function, tried placing the blueprint in the actor I’m trying to attach instead of the PC, created a new project and none of it works- please help :,))

player Blueprint

actor that I’m trying to attach

print string return in pink for this function (the other true is for overlap)

socket

Hello @Headless888 ,Welcome to the forums!

In this example, I used a Sphere Collision component as the reference object. First, I applied the following settings in the Details panel, under the Collision section. Then, I replaced the DefaultSceneRoot with the Sphere Collision component, making it the new Root Component, as this helps prevent collision issues later on.

Next, I applied the following settings to the Static Mesh (in this case, a sphere).

Inside the Event Graph, we’ll create a Boolean variable called bIsGrabbed and two Custom Events: one for the Grab logic and another for the Drop logic.


( If you don’t want the object to have physics, simply remove the Set Simulate Physics node.)
Both events will have an input that stores a reference to our character. In this example, I’m using the Third Person Template, so the input type is BP_ThirdPersonCharacter Object.

OnGrab


OnDrop

After that, we’ll create two Input Actions, one for Grab


and one for Drop,

and add them to the IMC_Default. In this example, I used the same key for both actions: pressing the key once grabs the object, while holding it for 0.2 seconds drops it. If you prefer, you can also use two different keys and set both Input Actions to use the Pressed trigger.

Then inside BP_ThirdPersonCharacter, we’ll create two variables: a Boolean called bHasObject, and another variable that stores a reference to the object currently being held. This ensures that the player can only hold one object at a time. In my case, I named it CurrentObjectInHand, and its type is BP_Object, which is the name of the object’s Blueprint.

Next, we’ll create two Custom Events that will be responsible for calling the events we previously created inside BP_Object.

To finish, we’ll add the corresponding logic to each Input Action. For the Grab action, we’ll perform a Sphere Trace to detect and interact with the object. If the trace hits a BP_Object, we’ll call the Grab event. On the other hand, if the character is already holding an object, we’ll call the Drop event to release it.

I also recommend checking out this video, which explains another way to create a Pickup, Carry, and Drop System that you might find useful.

Hope it helps!

Hello! Thank you so much for your reply! It seems to work now (although not entirely as I would’ve hoped but I’ll figure it out-) do you know then if the problem was the hierarchy? The problem is that I would like for the object to have physics enabled in the beginning, but somehow the collision needs to move with the object as well.. do you perhaps have a solution or any advice for that?

Hello again @Headless888 ,
Yes, that’s definitely possible. It could be that the object was moving while the collision stayed behind, or vice versa, which would explain the behavior you were seeing.

As for having the object start with physics enabled, you simply need to enable Simulate Physics on the object from the beginning. That should make it start simulating physics as soon as the game begins.

If you run into collision issues, it could be because the actor is colliding with the player’s capsule, causing it to be pushed away or launched. To verify that everything is set up correctly, you can use the Show Collision console command to visualize all collision shapes in the level.

You may also need to position the bone (or the point where the object is being held) outside of the player’s collision capsule. You’ll probably need to experiment a bit to see which solution works best for your setup.

Another thing that might help—and honestly what I think will work best in your case—is using a Physics Handle. I’ll leave you a forum post where I explain how to use it with an example, as well as a video that you might find useful.

If you have any other questions or run into any issues, don’t hesitate to create another post on the forum!. The community will be happy to help you!
Hope it helps!

@BRGEzedeRocco Sorry I only just saw this! Thank you so so much for all your help! I was very stumped on this and now I have an idea on how to move forward! Thank you!!