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

Simple game using farseer

Topics: User Forum
Mar 30, 2008 at 10:31 PM
I’ve created some simple physics game based on Farseer, you can see it at
It has only 6 simple levels so far, but I’m hoping to add much more in a near future when I remove some annoying bugs.

But I have some problems with Farseer to (or just simple I don’t understand how to use it properly):
Some bodies have tendency to flicker and it doesn’t look well, I don’t know how to solve it and sometime the bodies bounce from each other with a great force, without any reason…

If you have any comments or suggestions please let me know
Mar 31, 2008 at 12:27 PM
Nice game. A crayon physics clone, I see.

I think you need to set the Body.CoeficientOfRestitution lower. Also, try tweaking the PhysicsSimulator.Bias property. It defaults to .8. Lower values, say around .2, might give your objects a softer touch.
Mar 31, 2008 at 9:03 PM
Edited Mar 31, 2008 at 9:08 PM
Thanks, the idea was to have something between Crayon and this but it think I’ll need much more time to spent on it :)

I have following settings:
_physicsSimulator.Iterations = 50;
_physicsSimulator.BiasFactor = 0.1f;
_physicsSimulator.AllowedPenetration = 0.005f;
Geom objects.RestitutionCoefficient = .2f;
Geom objects.FrictionCoefficient = .03f;

So the bias factor is actually lower then you suggested and I couldn’t find attribute “Body.CoeficientOfRestitution”, could you help me with adjusting those settings again, I will do appreciate your help
Mar 31, 2008 at 9:46 PM
Wow, 50 iterations is way to many. You shouldn't need more than 10. I doubt that is your issue though.

The rest of your values look ok. You're right, RestitutionCoef. is on the Geom, not the Body.

Another thing to try and tune are the masses of your objects. You probably will want to make the mass dependent somewhat on the size for realism sake. For this you'll need to calculate the area of you objects. Larger area means larger mass.

Try also to increase gravity a bit so things aren't so light.
Mar 31, 2008 at 10:21 PM
I’ve changed iterations to 10, object’s mass was calculated as 1/100 of its area (in pixels), I’ve changed it to area’s equivalence and changed gravity from (0,100) to (0,200) but objects still shiver, however they behave much better now.

Maybe I shall tune SubDivideEdges(15) in polygons and numbeOfEdges in circles (96) to other values and I also use collsionGridCellSize == 0 (default from what I understand) but I don’t know to what values I shall change it, I’ve also noticed that when I’ve setup _physicsSimulator.Update(.02f); to values lower than .02 it tends to behave strangely

Apr 1, 2008 at 12:28 PM
Are you using pixels as your units throughout the game? If so, you may benefit some changing it so that units used by the physics engine are a bit more realistic. For my games, I usually use 50pixels = 1 simulator unit.

There is a ConvertUnits class that will help facilitate the conversions.

Doing somthing like this may keep the physics engine a bit more stable. I'm not sure why you are getting all that jitter. Something just isn't tuned right.
Apr 1, 2008 at 11:10 PM
I’ve setup everything (physics and coefficients) to default values, called physics engine update with .02f value, changed circle number of edges to 14 (from 96) and fixed mass for every body as 5, finally circles stopped to drill, but polygons still behave strangely

I’ve tried SubDivideEdges for values from 5 to 50 without any significant result .

Actually I don’t know what I’m doing wrong, your demo works smoothly and everything shakes in mine :)
Apr 2, 2008 at 10:26 PM

When I set RestitutionCoefficient to 0 it stop to drill, so now I don’t know where to look, any higher value and it drill again…

could it be something with distance between vertices in polygon (15) and collision grid cell size (5)

Apr 3, 2008 at 5:51 PM
Can you create a debug-view of you game? It might answer lot of questions.

Also, see the old .pdf doc at the bottom of this page:

It is old but it might give you better feel for how farseer collision works.

The jitter is odd. Hard to say what could be causing that without debugging the code 1st hand..
Apr 3, 2008 at 11:23 PM
Sure, did you mean System.Console.WriteLine, but what datas it should contain? I read that documentation long before and I think I’m following it right :)

Ps. I’m sorry for taking your time, but I can send you whole source code if you want to take a look at it.
Apr 4, 2008 at 6:10 PM
I mean a debug-view that will show you the vertices and edges of the geoms, collision points, etc.. Like in the demos if you hit 'f1' ( i think it's F1)

You can send the source to or send me a link to grab it. No gaurantees when I'll be able to look at it but I will shoot for sometime this weekend.

Apr 4, 2008 at 6:14 PM
I incorporated this debug view in my project and it REALLY is VERY useful. I was having a problem for hours and after I incorporated it, it only took one press of F1 to figure out what was wrong.

Actually I strongly suggest that Jeff incorporates it in the Farseer package.
Apr 5, 2008 at 9:26 PM
Right, I need to add it, but do you have any good solutions how to implement debug-view in Silverlight, Farseer has only such a debug-view examples for XNA and, I think, you can’t draw that easily (directly) on Silverlight canvas…