How can I find the location of a bone in a skeletal mesh that is simulating physics?

Hi there, I’m still slowly plugging away on this physics-based octopus game in my spare time. I’ve run into an issue with physics attachment and I think I’ve narrowed down where the root of the problem is. To summarize the problem, I have been trying to spawn a physics constraint at the hit location of a skeletal mesh and some other object. This works, but the physics constraint is left with an odd offset that causes some very strange behavior, as highlighted in this video:

In this example, I spawn the physics constraint at the bone's reported location and enabled it, basically locking the bone in place at where it was when the On Hit event fired. As you can see, this bone (which has a small sphere for its physics volume at the end of the tentacle) is no where near the surface.

In this image, I’ve further narrowed the problem by spawning some marker spheres on where the On Hit Event is reporting that the bones are:

In the above image, I’m spawning physics constraints when the tentacles touch the green platform below the octopus. You can see that the spheres are no where near the surface where the tentacles are actually touching. The spheres are placed over a few times hitting the “Attach” button, that’s why they’re spread out over some distance around the platform. I’d expect them to be at the location of the bone when it touches the surface, which I would suspect would be very close to the surface since the bodies attached to the bones are very small.

In the next image, I’ve disabled the rotation in the tentacles caused by the physics simulation. This highlights that the location I’m getting (Using Get Socket Location) is actually the location for the bone at the bind pose, not where it currently is in the simulation.

You can see that the markers are all on the surface where the skeleton is touching. This behavior aligns with my suspicion where the location given by Get Socket Location doesn’t give the location for the bone in the simulation, but rather where it is in the bind pose. I’ve tried adding custom sockets to the bones, but the function gives the same results. Again these results are over a few times of hitting the “Attach” button, so that’s why they’re in a few different spots, but they’re all on the surface as I’d expect.

Anyone have any idea how I might be able to find the location of a bone in a skeletal mesh that is using its physics simulation to flop around?

You should try in 4.7, there is similiar problem with particles attached to bones during ragdoll simulation:

https://answers.unrealengine.com/questions/142325/particlemodulelocationbonesocket-dont-follow-ragdo.html

And this is probably fixed in 4.7.

If not you can get position directly from body instance, but only in code:

GetMesh()->GetBodyInstance("yor bone name")->GetCOMPosition()

or

GetMesh()->GetBodyInstance("yor bone name")->GetUnrealWorldTransform()

Hope it will help you.

Regards

Pierdek

Cool! Thanks for the reply Pierdek, I will give it a try right now

4.7 looks like it’s fixed it hooray!

4.7 looks like it’s also introduced a number of stability issues, and other problems with physics- simulating skeletal meshes. I’ll write up separate bugs for those. Thanks for the advise Pierdek!

Updated to the 4.7 preview, and this behavior no longer happens. I’m able to get the bone locations as expected.

Heya!

I’ve been troubled by getting the wrong bone location during skeletal mesh physic simulation for months! This method solves the issue! :smiley: