Reputation: 41
I am currently using the Box2D Engine in LibGDX for my new game. Is there a way to change the settings of the fixture definition while the program is running?
Kr UbuLin
Upvotes: 1
Views: 476
Reputation: 20140
FixtureDef
is just prototype that create Fixture
for physics body, I think you want to change fixture of body at runtime.
Yes you can, suppose I want to change density of body that is already created.
Array<Fixture> fixtures=body.getFixtureList();
for (Fixture fixture:fixtures)
fixture.setDensity(2);
Then you need to call body.resetMassData();
to apply changes.
One more option you can destroy fixture of body and re-create with different configuration.
Upvotes: 1