Physics Constraint - Grabbing at hit location

I would like the player to be able to grab physical objects.
For this, I would like to use Physics Constaint because it is probably more realistic as well as extended than Physics Handle.
The problem is that Physics Constraint grabs the other object at Pivot Point, not at hit location.

So the idea of mine is to attach the grabbed object to the another static mesh and this parent will change the position on the hit location where the player started the interaction.
Here is the Blueprint content of the Physic Object that i wanna grab:

And here is my Grab logic in BP_FirstPersonController:

But it’s glitching out! And I also believe that such a thing is not possible, because in order to maintain realism, Physics Constraint has to grab the physical object directly, not its parent, which does not even have the right mass or Physics Material.

Here:


The Sphere Debug should be in Yellow Cube, but it’s in completly wrong position.

Any idea to make Physics Constraint attach to second component at Hit Location, not to pivot point?

I have no way to replicate your exact setup but you should be able to modify this to fit your needs:

  • World Hit Location is in world coordinates where the line trace hit the object we have to attach.
  • Local Parent Offset is where we want that hit location on the child to be moved in relation to the pawn. I used it to simply hold the object a bit in front of the pawn (200, 0, 0)
  • Ignore the Set Simulate Physics node. I tested it on the blue boxes in the FirstPerson example so I had to disable the their physics in order to drag them around.

great guy! i love it

It looks promising, but could I ask for more context?
Where is this function located?
What does the “self” block in the screenshot represent? The Player Controller or the object we are interacting with? I do my Grab logic in PlayerController, but the screenshot when I attach my grabbable cube to a parent object with a hit location position is in my BP_CubeTest blueprint
Thanks anyway for your reply!

Aw, this is an event in the character/pawn that the player controls.
If you want to make it in the controller you can replace self with GetControlledPawn() both when when attaching and when getting the transform and it should work.

Edit: Attaching to the controller wont work as the controller never moves. It only rotates. On the other hand the character never rotates up/down, only side-to-side, so if you want it really following your view you have 2 options:

  1. Correct the position when looking around.
  2. Attach it as a component to the camera (see how the weapon is attached in the default First Person Game)
1 Like

It works! Thank you.
I have to somehow solve the issue when it comes to the detach object from the Player Controller cuz my object destroys itself sometimes (I think it just detaching from the level because some sort of delay), but that will hopefully be a easy.
Thanks again!