# Box2D Issues determining the side of collision

I'm trying to determine which side of my object a collision is happening. In all of my searching, I have found 2 different proposed solutions, but each one has a major issue. I'm hoping that someone here can explain what steps I am missing.

Attempt 1 : Sensors

The first solution I tried was using Sensors on the sides of a Dynamic body. Like this :

The issue with this solution is that multiple sensors can easily collide with a single obstacle, like this :

My second solution was to get the Normal from the b2WorldManifold that is provided by the contact in BeginContact(). This works perfectly, but only for detecting the side when a collision begins, not when it ends. EndContact() doesn't have the ability to provide a World Normal. You can get the manifold, but the components of the Normal are undefined. The issue with this is that I have no way of knowing which collision just ended.

Hopefully someone knows enough about Box2D to see something simple that I am obviously missing. Thanks in advance for any input.

• The issue of 'which side is colliding' is a little vague. Will you always have an entire side of your fixture overlapping? Couldn't you just have one point of the green fixture inside the black one? Jan 15 '15 at 20:25
• No. What I need to know is positionally, is the object I'm colliding with above, below, left, or right of my object? For example, if I'm colliding with a Wall to the Right, and I'm not on the ground, then I can walljump to the left. Jan 15 '15 at 20:45
• ahh, ok. That helps. For wall-jumping (according to this answer), you could calculate the direction vector between the center of mass of your character, and the point of contact. Whenever the jump button is pressed, apply an impulse away from the wall along that vector. Does that work for you? Jan 15 '15 at 22:11