Different collisions

May 13, 2013 at 4:33 PM
I have 2 rectangles(red and brown) and 2 walls(red and brown).
I want to brown rectangle to go through red wall, and collide with brown wall.
And red ractangle collide to red wall. See the attached .jped too see my issue.

Can anyone help me to resolve my problem Image
May 13, 2013 at 5:10 PM
You can use CollisionCategories and CollidesWith for this. Set different CollisionCategories for each red and brown combination and then set CollidesWith.

Something like this:

PhysicsSprite spr = GameCanvas.PhysicsObjects["box"];
spr.BodyObject.CollisionCategories = FarseerPhysics.Dynamics.Category.Cat1;
spr.BodyObject.CollidesWith = FarseerPhysics.Dynamics.Category.Cat1 | FarseerPhysics.Dynamics.Category.Cat2;