Search code examples
androidandenginegravity

Can I make a Body immune to Gravity?


I want a PhysicsWorld where only some elements are affected by gravity (as set by the Accelerometer). I've tried setting the mass of some objects to 0, but this doesn't work. Is there any way of making some Bodys immune to the gravity of the world they're in?


Solution

  • Think about how you'd do it in the real world - you need an upwards force to counteract gravity to make something neutrally buoyant.

    So try applying an acceleration to the body which is equal and opposite to your gravitational acceleration.