0

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

Community
  • 1
  • 1
Libor Zapletal
  • 13,752
  • 20
  • 95
  • 182
  • I removed the *box2d* tag because this question is not related to box2d - it concerns only the *farseer* engine which, while a port, is a completely separate project. – JDB Oct 16 '12 at 21:16

1 Answers1

0

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.

cuongle
  • 74,024
  • 28
  • 151
  • 206
Remco Brilstra
  • 798
  • 5
  • 13
  • I tried it but it didn´t help. I looked at samples and I get my code from them. I´ll try check and look once more but if anyone can help me it would be better. I think I have everything allright. – Libor Zapletal Oct 17 '12 at 11:30
  • If i remember correctly you also need to make sure that you assign the object to a collision category and you also need to define the 'CollidesWith' property both for the particles and the pieces of the maze. I'll try to find that old project code so i can help you out here – Remco Brilstra Oct 17 '12 at 12:47