The Physics Handle won't work well with Physics Constraint Component

Hi!
I’m trying to make it so that when I lift a physical object, say a cube, it is grabbed at location with physics handle, and when grabbed, I want to freeze/lock its rotation, so it won’t swing around in the hold, and when I drop it should regain its physical simulated behavior and be able to rotate freely. This was not possible to accomplish in my knowledge by always setting it to a certain rotation in tick/update, didn’t even work with the physics handle “set rotation” function.

So I found that one can give, the objects to be lifted, the Physics Constraint component, which gives the option to switch between three different constraints: Lock, Limit or Free. Thus setting it to Locked when grabbed and Free when released works beautifully. It gives the exact behavior was looking for, except for that the objects now are flipping randomly upon grab… Mostly it’s working fine, but the initial grab of one of these objects can result in them jumping away to then lerp back to the grab position, and in some cases they completely disappear (most likely passing through the walls of the room due to its high speed or something.

It kind of looks like it could be a collision problem, but I have placed the grab location rather far out from the character, and as you can see in my blueprint in the attached screenshots, I do set the collision to ignore the player when grabbed.

UPDATE: I have found a clue to the issue: The objects seem to want to be at a certain rotation when grabbed, so for example if I grab an object, then make it roll over to another side by releasing it, then grab it again, it will flip back to the same rotation as of before…

My closest guess now is that the Lock and Limit mode of the Physics Constraint Component sets it at 0,0,0, so I think I just need to find out where to control this.

1 Like

I have found a solution to this now, but this scraps the Physics Constraint Component, which was the closest thing to a solution I got before I got this.

So the solution was simple but rather easy to miss. I simply made sure to have the node “Set All Physics Angular Velocity in Degrees” and its New Ang Vel set to 0,0,0, before it goes over to the node “SetRelativeRotation”. This way the rotation can be freely manipulated.

See Blueprint example below. This is run in Event Tick, with a boolean check for if an object is held.