How to detect side of collision

Topics: User Forum
Sep 23, 2011 at 4:03 PM

Hi all, I am writing a 2D project inspired by Karl Sims' work "Evolved Virtual Creatures": http://www.karlsims.com/evolved-virtual-creatures.html using FarseerPhysics 3.2 as physics engine.

My creatures are a chain of rectangular parts (rectangular fixtures) connected by circular joints (revolute joints). I encountered some problems while implementing contact sensors for each part, which are objects telling the part brain which sides of the rectangle is colliding with something (I don't care what) and which are not. How can I do? I'm pretty sure I need to look around Contact.Manifold but I still don't undestand where exactly :) I tried to use Manifold.LocalPoint or LocalNormal but it works only sometimes...

Oct 7, 2011 at 8:32 PM

Solved. For each Contact in the fixture's ContactList I call Contact.Manifold.GetWorldManifold, which gives out the world coordinates of a couple or a single contact point. After that I need to filter out contact points which don't belong to the fixture I am analyzing, and finally I can decide on which side of the rectangular fixture are placed the other contact points by tranforming them into local points with GetLocalPoint.