How to find if top of rectangle collided or not in box2d

59 Views Asked by At

I have rectangular player in top down game. I want to find which side(to be specific top of rectangle ) of rectangle is hit by other game objects.

1

There are 1 best solutions below

2
Laurence On BEST ANSWER

If you want to distinguish between collisions for different parts of your game object, use different fixtures for those parts. So if you want to distinguish between top and bottom for example:

-----------------
|               |
|Top Fixture    |
|               |
-----------------
|               |
|Bottom Fixture |
|               |
-----------------

These could also be sensors (so no physics) as an overlay for your other physics fixtures.