# Trying to setup physics-enabled dragging. Hitting some stumbling points

I’m trying to setup some physics-enabled dragging. This is for my entry for the Katamari Jam, where I’m trying to make an octopus you roll around. You suction things to the tentacles, and then torque your head to fling them around.

Early WIP video: YouTubeYkm-MlhuM

I’ve gotten some good results with physics constraints, but I’m running into a weird offset issue.

Here you can see the issue illustrated. The quadropus and his gooey tentacles are on the left, and the box he’s attached to is on the right. The physics constraint is at the blue corsshair on the box’s surface.

What is the red line? It seems to correspond to the distance that the constrained bone is kept at. Is there a way to move this point? Ideally I want it to be on top of the blue crosshair, or offset by the radius of the physics body attached to the bone.

Anyone have any idea what I’m looking at here?

Put together a little video highlighting how this manifests in-game.

I read through the docs here Physics Constraint Reference in Unreal Engine | Unreal Engine 5.1 Documentation

So it looks like this is the offset from the component being constrained to the constraint. That kind of makes sense. I move the constraint to the hit location in world space.

This distance looks really far from the bone being constrained in most cases though. Even if I make the colliding bodies spheres, I still wind up with a really large distance sometimes. Is there a way to manually set the distance?

Added a new quick video that illustrates what’s happening.

Why would the constraint be locking to this location? It doesn’t seem related to either component nor actor involved

Shanthosa posted this (at my request) on Reddit. Posting it here for posterity.

It seems to me the problem is the limited linear constraints - I think they need to be locked to get the behavior you’re looking for.

Edit: Nope, sadly that’s not the problem either.

Link to the reddit thread as well for posterity. Thanks again for the help!

So I came up with a pretty jank solution, but it seems to work pretty well!

The work around for this for me was to move the actor I hit with my tentacle by a distance equal to the distance from the bone I’m constraining to the hit location. This will close any gap between the object and the bone generated by this weird offset. I fix it up by finding the actor’s location during the hit event, and then resetting it to that location after constraining the components together.

To summarize it looks like this:

Store original location of the other actor → Move other actor toward the bone’s location according to the distance between the bone and the hit location → Constrain the components → Reset the other actor to its original location

Here’s a video of it in action: https://www.youtube.com/watch?v=YMw7OVcpRgM

Thanks everyone so much for your help!

I’d actually like to circle back around to this issue again, if anyone is available to help diagnose what’s going on. My workaround only got me so far.

As I’ve moved forward with this project, I’ve hit another stumbling block when I wanted to start attaching two simulating skeletal meshes together at runtime. Because I can’t use the following solution to move the simulating bone’s physics asset, my workaround doesn’t work.

Normally, the way my hit event handling works for attaching is the following:

1. Store the Hit Mesh’s (Mesh my tentacle has hit) current transform
2. Move the Hit Mesh to a new location that’s equal to the distance from the Hit Location to the Bone I’m attaching to’s location plus the Hit Mesh’s Actor’s location. I also move the constraint from the generated position on the hit surface to the Hit Bone’s location. This stacks all three components on top of each other. This is the only way I’ve been able to get a physics constraint to not have some weird offset to it.
3. Do all of my attachment work, including Setting the Constrained Components and their bones
4. Move the constraint back to its original location, then move the Hit Mesh back to its original location

With that setup, its possible to setup a physics constraint that attaches a movable object and a skeletal mesh. I’ve run into the problem where I get the same offset problems with other skeletal meshes and Static (non-movable) Static meshes. I’d love for this solution to be as flexible as possible, so I’m trying to figure out why my physics constraints are behaving like this.

My expected behavior was something like:

1. Use AddPhysicsConstraintComponent, passing in the hit location converted to the relative transform as it’s spawn location
2. Use SetConstrainedComponents on the generated constraint, passing in the appropriate components and bone names

Anyone have any insight at all to offer?

I think I may have stumbled upon part of why my workaround works, and maybe part of why this is happening. It looks like the On Hit Event is firing and being processed before the body actually makes contact.

I setup a quick debug scenario, where the bones will setup constraints that are placed on the bone that makes contact, and then attach to nothing (rooting the bone in place). What I saw was that the bones would make contact, but then snap back to some position away from the surface, seemingly before the physics body for the bone makes contact.

Here’s a video of the behavior:

Any ideas what I'm looking at here? I think this might be part of the root of these issues

Anyone have any idea? Still running into this. Crying myself to sleep each night as I bang my head against it

Still don’t have a really good solution for this.

To summarize, it looks like the attachment isn’t happening at the right spot and / or on the right frame. The distance from the reported hit location to the actual point on the surface that was hit is pretty drastically different.

Hey thanks for the reply! I had tried out the physics handle once before but it wasn’t getting me the results I wanted. I will try out this tutorial though! Looks super helpful.

Also what the hell? How do I pin wires to points in the blueprint grid? That looks like a super important piece to keep my blueprints organized.

As for a blog, I’ve only been using a WIP thread but I haven’t updated in a while since I haven’t been working on this lately. Any updates I do post will be here: Octopus Katamari-like - Game Development - Unreal Engine Forums

Octopus Simulator 2015 perhaps

Very funny game. XD

Can you post any link to this game or blog?

Thanks! Game is awesome!
Maybe you go to Steam Greenlight?

I will wait for this game and buy, or donate!

Hey so I did try this out, but I’m not sure handles will give me what I want. They don’t seem to really allow for the two simulating bodies to interact in the way that I want. It really seems to take over the body being dragged completely and have the parent drag the other around. With constraints the two bodies will interact and take both their weights into consideration when applying forces to each.

I may try again with some more tweaking of settings, but for now I think I am going to move forward with my more limited physics constraint-based solution. Thanks for the tip! Definitely worth investigating more.

Dug even deeper. Found that the bone location given through On Hit for Hit Bone is not correct at the time of the On Hit. It is the location of the bone in the mesh’s bind pose, not it’s current location in relation to its simulation.

Anyone have any idea how to find the socket or bone location of a physics-enabled skeletal mesh?

Updated to 4.7, and now the bone locations for physics enabled skeletal meshes are correct when gotten through blueprint, as outlined in this issue: https://answers.unrealengine.com/questions/149982/how-can-i-find-the-location-of-a-bone-in-a-skeleta-1.html

Thanks everyone for your help!