ruploz
ruploz

Reputation: 31

Java libGDX Box2D: can you set center of mass manually?

As title asks, can you change the center of mass of a body, or is it stuck with the automatic calculation of center?

I could probably do it with multiple fixtures, but is there another way to manually set the center?

Upvotes: 1

Views: 2193

Answers (1)

Zyion
Zyion

Reputation: 191

You can set the center of mass like so

    b2MassData* data;
    body->GetMassData(data);
    data->center.Set(0, 0);
    body->SetMassData(data);

Upvotes: 1

Related Questions