Center of Mass Not Updating, Should be Simple

This has been quite a couple of frustrating weeks trying to figure out this issue.

I have a static mesh as a root of a Pawn. I’m attempting to override the center of mass of the Pawn to match the origin of the actor’s static mesh. To do this, I’m calling these two lines at every call of Tick():

meshComp->SetCenterOfMass(GetActorLocation() - meshComp->GetBodyInstance()->GetCOMPosition());
meshComp->GetBodyInstance()->UpdateMassProperties();

Then, to test the update, I do the following later on in the Tick() function:

meshCOM = meshComp->GetBodyInstance()->GetCOMPosition();
meshLoc = GetActorLocation();
float temp = (meshCOM - meshLoc).Size();

The value of temp should be very close to 0.0. But it’s not. It’s like PhysX is completely ignoring my center of mass override call.

This should be absolutely simple, but has caused me an incredible amount of headache. For anyone who has worked with PhysX and it’s actions on static meshes, what can I do here? I’m absolutely stuck. Thank you in advance.

Well, of course I found a solution that seems to work immediately after I post this question. It turns out, if I set an extra parameter to the mesh component’s body instance, it works:

meshComp->SetCenterOfMass(meshComp->GetBodyInstance()->GetCOMPosition() - meshComp->GetBodyInstance()->GetCOMPosition());
meshComp->GetBodyInstance()->COMNudge = GetActorLocation() - meshComp->GetBodyInstance()->GetCOMPosition();
meshComp->GetBodyInstance()->UpdateMassProperties();

Now, why I have to set both COMNudge, and call SetCenterOfMass(), is beyond me. But I am only successful if I call both. I’ve seen a lot of questions on here regarding only setting SetCenterOfMass(), but nothing about COMNudge.

However, upon looking deeper into what UpdateMassProperties() does, this function call updates the center of mass based on COMNudge, not SetCenterOfMass(). So it seems like in general, any mass changing functionality should be done through the body instance too, not just the mesh component itself.