Get X and Y coordinates from collision in Box2dweb (JavaScript)

38 Views Asked by At

When there is a collision in Box2dweb, this class create some objects. b2ContactListener.prototype.BeginContact

From there I can access a lot of data with:

var a = contact.GetFixtureA().GetUserData();
var b = contact.GetFixtureB().GetUserData();

Yet I can't find the way to get the X and Y values of the collision with some seudo code like this.

var aColX = contact.GetFixtureA().GetBody().GetPosition().x;
var aColY = contact.GetFixtureA().GetBody().GetPosition().y;

What's the right way to get this data from contact.GetFixtureA()? //Object A

1

There are 1 best solutions below

0
user20218381 On BEST ANSWER

This is the answer.

var aColX = contact.GetFixtureB().GetBody().GetTransform().position.x;
var aColY = contact.GetFixtureB().GetBody().GetTransform().position.y;