0
\$\begingroup\$

I've discovered a bizarre issue with the Farseer Physics Engine that I can't figure out. I have two Farseer bodies that I'd like to only collide with each other. To that end, I have the following code.

body1.CollisionCategories = Category.Cat1; body1.CollidesWith = Category.Cat2; body2.CollisionCategories = Category.Cat2; body2.CollidesWith = Category.Cat1; 

Which works fine. However, if I switch the categories around (shown below), the bodies no longer collide.

body1.CollisionCategories = Category.Cat2; body1.CollidesWith = Category.Cat1; body2.CollisionCategories = Category.Cat1; body2.CollidesWith = Category.Cat2; 

Some additional notes that might be relevant:

  • body1 is static, while body2 is dynamic.
  • body1 is created before body2 (although I switched the order and nothing changed).

Does anyone know why this happens? Based on my understanding of how Farseer uses collision categories (i.e. as masks using bitwise operations), the order shouldn't matter. Is it something silly I'm missing?

Thank you.

\$\endgroup\$
2
  • \$\begingroup\$ The order here should not matter. Are you changing anything else between tests? \$\endgroup\$ Commented Sep 26, 2016 at 11:12
  • \$\begingroup\$ Not that I'm aware of, no. I guess there must be something. I'll have to do more digging and update this question later when I know more. \$\endgroup\$ Commented Sep 26, 2016 at 21:20

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.