Physics constrain child static mesh component default to root component

Hi, we have a blueprint which dynamically generates “tetris” blocks consisting of multiple static mesh cubes attached in an hierarchy. The root component has physics enabled.

We also have the FPS blueprint where you can pick up things with a physics constraint. As it is setup now when aiming and clicking with the mouse we shoot a line trace and if a block is hit we use the “Set Constrained Components” node and attaches a static mesh component on the FPS blueprint (which acts as the hand) and the hit component.

The problem is that even if the line trace returns one of the child components and we use it for constraining, the constraint is always centered on the root component which makes the picked up item jump.

  • Is there a way to configure the
    physics constraint to not center
    around the root component?
  • Or perhaps
    there are better approaches for this
    scenario?

Thank you.

304821-ezgif-2-7166f519b6cf.gif

Everything is centered around the actor origin point, so the origin of the parent component will be the origin of the entire object.

How many different configurations can there be? Maybe you can just create a bunch of different tetris pieces and set their origin at the center of mass? Then just randomly select a piece to spawn, instead of generating one from cubes.

Even if we had a curated list of blocks the problem would still be that the grab point would have to be static. One of the goals is to have the player be able to grab the edge of bigger blocks and drag them.

One thought I came up with in the middle of the night, but I never tried it and it may be stupid:

What if after the line trace hit, you spawn another empty actor at the impact point, parent all the blocks to this empty actor, and move this empty actor with the physics handle? In this case the grab point should not change, but I’m not sure how the block will behave.

Well, it kind of works. Here: https://i.imgur.com/GYjNwIO.mp4

The grab point remains where the line trace hit. You’ll have to work on the large mesh behavior though, maybe set some constraints or damping, etc.

Thanks! Although I wanted to try without using a physics handle but I got inspired by your solution of spawning a new actor. The actor contains a physics constraint and when spawned at the hit location will attach the block to itself and constrain the players “hand” with the block.

It looks like a potential solution, thanks again! :slight_smile: