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

Planetary Gravity

Topics: Developer Forum, User Forum
Nov 5, 2009 at 9:06 PM

Hello everyone!. I am using Farseer XNA Version 2.1.2 and I see in the documentation that since Farseer 2.1, you can use "Planetary Gravity". I need this because I am making a space game that needs multiple gravity points within the game world. Where is the class to get this kind of gravity to work? How do I make it work? I don't see any documentation on it, so please let me know how to enabled Planetary Gravity in my game because I truly need it.



Nov 5, 2009 at 9:24 PM

Nevermind guys. I now see that you have to use the GravityController class. Thanks anyway.

Nov 5, 2009 at 9:25 PM

You can use the ComplexFactory.CreateGravityController() method to add a GravityController to your PhysicsSimulator. The GravityController works on both bodies and simple points.

Create it like this:


List<Bodies> bodies = new List<Bodies>();

GravityController gravityCont = ComplexFactory.CreateGravityController(physicsSimulator, bodies, GravityType.Linear, 100, 150);
gravityCont.PointLists.Add(new Vector2(100, 200));


Warning: This code has not been tested and was directly typed into this post.