Search code examples
c#windows-phone-7windows-phone-7.1farseer

Farseer - Particles just go thru another body


I am creating my maze like this:

agentBody = BodyFactory.CreateBody(world, position);
_agentBody.BodyType = BodyType.Dynamic;
_agentBody.IgnoreGravity = true;
_agentBody.Restitution = 0.1f;
_agentBody.Friction = 1f;

_offset = ConvertUnits.ToDisplayUnits(1.5f);

FixtureFactory.AttachRectangle(3f, 0.1f, 1f, new Vector2(0, 1.55f), _agentBody);
FixtureFactory.AttachRectangle(3f, 0.1f, 1f, new Vector2(0f, -1.55f), _agentBody);
FixtureFactory.AttachRectangle(width, 3f, 1f, new Vector2(-1.55f, 0f), _agentBody);
FixtureFactory.AttachRectangle(width, 3f, 1f, new Vector2(1.55f, 0f), _agentBody);

and my sand particles like this:

for (int i = 0; i < 8; i++){
    _sands[i] = BodyFactory.CreateRectangle(_world, 0.05f, 0.05f, 1f);
    _sands[i].IsStatic = false;
    _sands[i].Restitution = 0.1f;
    _sands[i].Friction = 0.1f;
    _sands[i].Position = new Vector2(1.8f + i * 0.2f, 2.2f);
}

_sand = new Sprite(
    ScreenManager.Assets.TextureFromShape(
        _sands[0].FixtureList[0].Shape,
        MaterialType.Dots,
        Color.SandyBrown, 0.8f
    ));

I checked fixture in debug view and it looks fine. But it isn´t. When particles appear on the screen they fall down (because of gravity) and go through my maze borders without any problem and they stop at the bottom where there's a static body. Why is that? Why don't particles stop in my maze?

For context, please see my previous question:
Farseer - Particles doesn´t move/bounce accord to borders


Solution

  • I'm not very fluent with farseer, but what i can remember from a project a while back was that we used the 'CollidesWith' property of a fixture

    something like :

    fixture.CollisionFilter.CollidesWith = CollisionCategories.All;
    

    otherwise the discussion board of codeplex project can provide a lot of information.