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.
You can find my original [thread about this issue here][1]
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.
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?
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
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:
Store the Hit Mesh’s (Mesh my tentacle has hit) current transform
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.
Do all of my attachment work, including Setting the Constrained Components and their bones
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:
Use AddPhysicsConstraintComponent, passing in the hit location converted to the relative transform as it’s spawn location
Use SetConstrainedComponents on the generated constraint, passing in the appropriate components and bone names
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
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.
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?