Hi. I am making a game using Box2DX.
Basically I have a player and some gameObjects. All gameObjects (and the player) have a Body.
Collision works fine. Now I want to get the points of contact. I have found no documentation about how to do it.
So I used
Box2DX.Dynamics.PolygonContact.
Here's my code:
Code:
// find GameObjects that collide with the Player
foreach (GameObject o in gameObjects)
{
Box2DX.Dynamics.PolygonContact contact = null;
Box2DX.Collision.Shape s1 = player.obj.body.GetShapeList();
Box2DX.Collision.Shape s2 = o.body.GetShapeList();
while( s1 != null )
{
s2 = o.body.GetShapeList();
while (s2 != null)
{
contact = new Box2DX.Dynamics.PolygonContact(s1, s2);
if (contact.GetManifoldCount() > 0)
{
Console.WriteLine("Contact {0}", contact.GetManifoldCount());
}
s2 = s2.GetNext();
}
s1 = s1.GetNext();
}
}
Nothing is printed though (because contact.GetManifoldCount() is always zero). What is wrong here?