Search code examples
c#xnafarseer

Farseer Physics Bodies In touch (in contact)


I am new to Farseer, developing a xna + Farseer physics game. There are multiple Physics bodies(square,circle, rectangle shapes) in the game, trying to findout all of the bodies in touch (touching each other), i can calculate based on the width/height but this will not be accurate. i would like to know any other ways or any in built functions in Farseer physics


Solution

  • Check out this answer for a lot of details. You may be able to use one of the events listed in that answer directly, depending on your needs.

    But, otherwise, you can get Contact objects by either "collecting" them from one of those events, or by extracting them from Body.ContactList (which is a linked list made up of ContactEdge objects).

    Note, of course, that a Contact might not actually be touching (it just indicates a potential collision). Use Contact.IsTouching() to check for that.