Changing the density of a physics object (after creation)

Is there a relatively simple way to change the density of a physics object after it’s been created?

I have a rocket and I’d like the weight of it to be dependent on the amount of fuel it has. Sure I can adjust the thrust levels, but changing the density (weight actually) would be more correct.

Hi @runewinse,

You can’t change the density post-body-creation. However, if the rocket is going upwards only, you could adjust the gravityScale property.

http://docs.coronalabs.com/api/type/Body/gravityScale.html

If the rocket can move about in 360 degrees (top-down view perhaps), I think just factoring down the thruster power (as you suggest) would look fine. If you’re using something like applyForce(), and you divide the “normal” thrust power by some value, it would behave effectively the same as if you applied the normal force to a heavier body.

Take care,

Brent

Hi @runewinse,

You can’t change the density post-body-creation. However, if the rocket is going upwards only, you could adjust the gravityScale property.

http://docs.coronalabs.com/api/type/Body/gravityScale.html

If the rocket can move about in 360 degrees (top-down view perhaps), I think just factoring down the thruster power (as you suggest) would look fine. If you’re using something like applyForce(), and you divide the “normal” thrust power by some value, it would behave effectively the same as if you applied the normal force to a heavier body.

Take care,

Brent