This project has moved and is read-only. For the latest updates, please go here.

Control Fixture by Gravity

Topics: Developer Forum
Jan 17, 2011 at 11:56 AM


I have a world with gravitiy  (World = new World(new Vector2 (0, -50));) - so all bodies falling down ...

Second i have a Fixture in this world, lets say a rectangle and want to move this by changing the gravity.X value (e.g. World.Gravity.X = value) of the world where it is in.

This rectangle should interact with other fixtures. But if I but the other fixtures into the same world as the rectangle the change of gravity will influence them too. If i put them into two different worlds the rectangle could not collide with the other fixtures. Somebody know a way to implement this? If so pls tell me! :) Thanks!

Jan 17, 2011 at 12:48 PM

Gravity is nothing more than a force, that is applied to each body on each world.step(). You could set the rectangles body to ignore gravity and apply its custom gravity by hand on each step. Either via Body.ApplyForce() or by implementing your own gravity controller and attaching it to the rectangle. Have a look at the PointGravity controller if you need a heads up on how to implement controllers.

Jan 17, 2011 at 9:36 PM

Many thanks for the info!