# \[PHYSICS\] Center of mass needs a rework

**URL:** <https://forums.unrealengine.com/t/physics-center-of-mass-needs-a-rework/98751>\
**Category:** Feedback & Requests\
**Tags:** unreal-engine\
**Created:** [August 18, 2017, 10:51pm UTC](https://forums.unrealengine.com/t/physics-center-of-mass-needs-a-rework/98751 "2017-08-18T22:51:22Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![BoredEngineer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BoredEngineer](https://forums.unrealengine.com/u/BoredEngineer)\
**Post date:** [August 21, 2017, 7:23pm UTC](https://forums.unrealengine.com/t/physics-center-of-mass-needs-a-rework/98751/9 "2017-08-21T19:23:39Z")

</div>

> [@Moddingear;752657](#):
>
> I don’t think there is a bug, I might just be confused by my actor between World Transform and Relative Transform. I actually just tested that, and it is indeed world space.  
> I am indeed trying to set the center of mass on a child RuntimeMeshComponent being simulated.  
> The COM could be relative to the origin of the component, such as if the component was a mesh, setting the COM somewhere would use the same coordinate system as the mesh’s. Since all welded components are child of this component, they would only have to get the center of mass relative to the simulating component, so I see why the COM is returned in world space.
> 
> BUT, and that is why I’m complaining, the COM is only being set using an offset as you mentioned, and doesn’t override the default COM, meaning that at any change of the geometry, the COM is being recalculated which adds a lot of overhead for nothing.
> 
> The solution that I am proposing is that GetCenterOfMass stays the same, but that SetCenterOfMass gets a OverrideCOM just like Mass does, in such that it doesn’t rely on the calculated PhysX COM.
> 
> And, I really appreciate you responding to my criticisms.

I hear you. Yeah, agree with that, would be very useful option to set COM directly. I’m not sure why devs added offset instead of override, perhaps something related to how code is structured or how it’s fed to PhysX. Don’t know exactly.

If you are in dire need of such change, this is the code for c++ function to set InertiaTensor:

```auto

void UMMTBPFunctionLibrary::MMTSetInertiaTensor(UPrimitiveComponent * Target, const FVector& InertiaTensor)
{
	FBodyInstance* BodyInstance = GetBodyInstance(Target);
	if (BodyInstance != NULL) {

		PxRigidBody* PRigidBody = BodyInstance->GetPxRigidBody_AssumesLocked();

		if (PRigidBody != NULL) {

			PRigidBody->setMassSpaceInertiaTensor(U2PVector(InertiaTensor));
		}
	}
}

```

For center of mass you can replace “PRigidBody-\>setMassSpaceInertiaTensor(U2PVector(InertiaTensor));” with this line:  
PRigidBody-\>setCMassLocalPose( [NewCenterOfMassTransform] );

Transform here is not FTransform but PxTransform of Physx. Haven’t tested it but should work.

---

_[View the full topic](https://forums.unrealengine.com/t/physics-center-of-mass-needs-a-rework/98751)._
