This project has moved. For the latest updates, please go here.

Another newbie question...

Dec 23, 2010 at 3:18 AM


I was hoping to develop a forms application that basically calculates a bodies position/velocity after forces have been applied to it. When I found the farseer work this looked very promising as it countains all the logic I would ever require in a far more thorough and elegant way than I could achieve.  Mine is not a graphical intensive program and I was hoping to use a forms project but I have noticed that there are references to a number of XNA objects such as Vector2 and Gametime so I was wondering whether this could be used in a .NET form or if there are too many XNA references to migrate it across (without huge effort). If it is possible what would the suggested approach be? Simply creating a world and adding a body and forces appears straight forward but the update() would depend on the game loop? - Would it be as simple as setting up my own loop to call an update process?

Thank is advance


Dec 23, 2010 at 4:14 PM

If you download the .NET library version you should have no dependencies at all as they are already included in the library.

As for the game loop, you simply create a loop by your self that updates the engine.

Dec 24, 2010 at 3:29 AM

Hi and thanks for the reply. I am now using the .NET package rather than the XNA one - off to a good start :). Now, about the loop.....

a) I wasn't sure what method to call for the farseer engine to "recalc" positions, speeds etc of bodies; and if I did

b) I assume Farseer needs to know exactly how long it has been since the last update was run. If I were to take a very simple approach and use a timer to fire this "Update" method every 5ms then this would be ok but what happens if for some reason the computer were busy doing someing and it couldn't fire the update until 15ms or 100ms had elapsed. Does Farseer keep track of the time between updates?  I noticed the use of a Gametime object under XNA - is this still used under the .NET model?

Again, thanks for any help and Merry Xmas.


Dec 24, 2010 at 3:06 PM

You need to call World.Step() and it takes in the delta time (time since last update). It does work with variable timestep, but the engine prefer a fixed timestep.

I would recommend you run the simulation at 30-60 Hz (we support 5-200 Hz as I'm usually testing the engine in that range). It is been a long time since I've used FPE outside of XNA, but I remember a timer class in .NET that has an Elapsed event. Inside this event you should call World.Step() and give it the delta time since the last World.Step().

Dec 25, 2010 at 12:28 AM
Edited Dec 25, 2010 at 12:29 AM

Shawn Hargreaves also wrote something about it on his blog:


Dec 26, 2010 at 3:41 AM

Great - thanks for the help.