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


Sep 16, 2008 at 5:05 AM
hi, how i can make collision between shapes in silverlight? or its support only rectangles and circles?
Sep 16, 2008 at 8:24 AM
Create 2 bodies and 2 geoms. Put each geom into different collision groups and make them bump into each other. Thats all :)

Have a look at the Demo 2 from the samples. They demonstrate it very well.
Sep 16, 2008 at 11:38 AM
When i create rectangle using Vertices.CreateRectangle collisions works, but when i triangle they stop working. Its a bug or i do something wrong?
Sep 16, 2008 at 11:45 AM
Create a rectangle like this:

Note that I don't have access to any code or tools right now.

Vertices vertices = new Vertices();

Geom geom = GeomFactory.Instance.CreatePolygonGeom(physicssimulator, vertices..... so on)
geom.CollisionGroup = 1;

Geom geom2 = GeomFactory.Instance.CreateRectangleGeom(physicssimulator, ..... so on)
geom2.CollisionGroup = 2; // Geoms in different groups collide with each other.
Sep 20, 2008 at 7:13 PM
I made 2 those triangles but they does not collide. Some times they collide but its very buggy.I dont need create Body objects?
Sep 20, 2008 at 9:26 PM
You should also create bodies.

Can you pack up the project that you have problems with and send it to me? (or send it to an upload service.)
Sep 22, 2008 at 7:11 AM
Edited Sep 22, 2008 at 7:12 AM

I posted source code before in this topic, but nobody replied=( 

source code:

Sep 22, 2008 at 1:49 PM
I going to take a look at it now. I must have overlooked your thread from before, sorry about that.
Sep 22, 2008 at 2:02 PM
Edited Sep 22, 2008 at 2:05 PM
Oh, okay. Now I see your problem.

The shapes are entering each other, this can be prevented by tweaking 2 factors:

1. Collision Grid Size
2. SubDiviceEdge

The first one is size of the cells in the grid that Farseer uses for collision detection. The smaller the size, the better accuracy. But a smaller grid cell size altso equals more computation when creating the grid. You try setting the gridcellsize in the GeomFactory.Instance.CreatePolygonGeom() method's parameter to a smaller size than the default.

The second solution is to insert more vectors/points/polygons in the corners. You can use the Vertices.SubDivideEdges(float) to insert more polygons on the edges.

Try out each of them and see what happens. There are also some other discussions with the same "problem" that you might want to take a look at.

You might want to take a look at this coding standard from Lance Hunt (Microsoft). You may have your own standard, but following a real coding standard takes care of a lot of naming issues and conflicts.

I also saw that you have Resharper 4.1 installed, try installing the Agent Smith plugin for Resharper (or CodeStyle) to keep track of inconsistent code style. (remember to configure Agent Smith to conform with the Lance Hunt coding standard)
Sep 23, 2008 at 5:00 PM

thanks for agent smith plugin

collision grid size does not effect , and with SubDiviceEdge collision works even worse =(