How to find Center of Mass?

I see that UE4 issues my models a mass, which it really seems to want me to use. Where can I see how this mass is distributed? I need to know where the Center of Mass is for physics calculations!

You model game assets for looks, so I need to make sure I’m not getting weird CoM’s on complex geometry. Clearly UE4 must know where it is, can I see it somewhere?

I hope I’m missing something because it’s incredibly dumb if I can offset something without being sure where it’s at in the first place.

1 Like

Hi slh3410,

You only need to worry about the Center of Mass if you are going to simulate physics on an object. The CoM is the exact center of your object and you can change that value by going to the Details panel > Physics > Center of Mass Offset.

For instance, if I want this rock to fall at an angle but roll onto it’s bottom after it hits, I just changed the Z value to -50.

Hope that helps.

Thanks, TJ

Clearly I’m going to simulate physics on an object then =)

My whole point is that with complex geometry, there is no obvious center I can use to approximate CoM. I believe using multiple materials on an object will also complicate things further.

I don’t know if the editor has the ability to show you the calculated CoM, but if you are confortable using C++ then you can use FBodyInstance::GetCOMPosition(), like this for exemple:

FBodyInstance *Body = GetRootPrimitiveComponent()->GetBodyInstance();
DrawDebugSphere(GetWorld(), Body->GetCOMPosition(), 200.f, 32, FColor::Yellow);
1 Like

I am the opposite of comfortable with C++ at this point, and Blueprints make it too easy to stay that way ^^

Thanks for the solid answer though. I mean obviously it’s in the engine somewhere, they need to add a toggle right next to CoM offset that highlights where it’s at, you know? Seems like an oversight.

As long as you are combining the meshes on import it shouldn’t matter how many material elements you have, it will still pick the center of the combined object. A good asset to test this on is the Lava Knight from the Elemental Demo, who has 4 material elements.

Indeed. Curiously enough, there actually is a native function to draw the CoM, it’s used in PhAT and when debugging the new vehicle systems.

Ok so TJ accepted his own answer to my question.

His answer was not satisfactory and this is an ongoing issue I have with UE4. I know the engine calculates the exact coordinates of the CoM- it has to in order for CoM offset to be possible. Why not let us call this location as a built-in feature?

Hi slh3410,

Sorry about that, I actually don’t recall excepting any answer for this question.

Perhaps you could post some screenshots of your model so we can get a better idea of what you’re trying to accomplish with such a precise center of mass?

It’s no problem, I’m not sure if there is an answer right now.

I want precise CoM coordinates in order to calculate moments. I think we should be able to call the CoM Position with Blueprints or code, and I think there should also be a little toggle next to CoM Offset that draws the debug sphere for you. I know the data is there already. I just think it’s ridiculous to let you move the CoM up or down or left or right without even knowing where it is in the first place! It might be good enough for simple applications but it’s not enough for anything more than doing it based on trial and error or feel or whatever.

As for what I’m trying to do, I want to build a physics simulation using a spacecraft model I built. To do this I need precise distances from my thrusters to the CoM. I know it’s much easier to just fake everything, but I’m trying to have some realistic fun with my models.

Thinking about it I guess I can solve for it pretty easily, I just have to experiment. I guess that’s the whole point of programming anyway, solving problems! I’ll learn =)

Edit- Alright yeah, I just took like 10 minutes to throw some physics thrusters on my model and mess with the values until I have zero angular velocity. CoM found…look at me solving my own problems! Next time I’ll do that before the wall of text post ^^

Hi everyone,

I know it took some time but this feature has now been implemented in the 4.6 release. Every physics object now has a small green sphere that indicates the center of mass. On larger meshes it will be inside of the asset, so the easiest way to accurately set the CoM is to use the Wireframe Orthographic view.

You can find more info about the changes and updates to the 4.6 release in the link below.

Cheers,

TJ

This is excellent and simple. I’ve been trying to add torques to a rather complex mesh this past week with non-promising results because of the slight difference between GetComponentLocation() and GetBodyInstance()->GetCOMPosition(). Mush simpler than calling some weird PhysX transform calls. Thanks for this.