I'm currently developing my own game but I'm facing a little problem. I am trying to figure out how to get the position of a fixture (collision) between two entities.

For example this:

enter image description here

(the grey rectangle is the player and the greens is an entity (not moving)).

With this code :

        Array<Contact> contacts = levelDatas.world.getContactList();
        try {
            for(Contact contact : contacts) {
                if(contact.getFixtureA().equals(playerBody.getFixtureList().get(0))) {
                if(contact.getFixtureB().equals(playerBody.getFixtureList().get(0))) {
        } catch(GdxRuntimeException exp) {

I get all the collision between a player and something else. But my problem is that I want to know where the collision is happening (on the left? on the right? bottom? top?). We can see that if there is a collision between 2 entities, a little point is draw. Anyone have a tip to give me the position of the collision?



When two fixtures collide, there are most of times multiples collisions between them, you can see those collisions with :

for (int i = 0; i < contact.getWorldManifold().getNumberOfContactPoints(); i++) {

1st you check all collsion number, then you will get the X and Y position of the given 'i' index.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.