Aug 22, 2012 at 11:49 AM
Edited Aug 22, 2012 at 11:51 AM
Thank you for your reply.
I did get my vertex geometry code working as it should now and I am able to see that they are moving around the world as they should, following the body.
And in my debug console I am following the position and the rotation of the bodies, their values just pass through eachother as if they never had contact.
Falling straight through the static body.
I did make some changes to my code after my last post, I tried co clean it up even more and decrease the margin of error.
What I ended up with is now this:
physicsWorld = new World(new Vector2(0, -10f), true);
physicsWorld.WarmStarting = true;
physicsWorld.ContinuousPhysics = true;
I enabled warm starting and continous physics.
Also, now I only create 2 bodies, a static rectangle and a dynamic box. As I understood it a dynamic objects does collide and responde to contact with a static one.
BodyDef rectangleDef = new BodyDef();
rectangleDef.type = BodyType.Static;
rectangleDef.position = new Vector2(0, -30);
rectangleDef.angle = 0;
Body rectangleBody = physicsWorld.CreateBody(rectangleDef);
PolygonShape rectangleShape = new PolygonShape();
FixtureDef rectangleFixtureDef = new FixtureDef();
rectangleFixtureDef.shape = rectangleShape;
rectangleFixtureDef.density = 1;
BodyDef boxDef = new BodyDef();
boxDef.type = BodyType.Dynamic;
boxDef.position = new Vector2(0, 5);
boxDef.angle = 0;
Body boxBody = physicsWorld.CreateBody(boxDef);
PolygonShape boxShape = new PolygonShape();
FixtureDef boxFixtureDef = new FixtureDef();
boxFixtureDef.shape = boxShape;
boxFixtureDef.density = 1;
I also changed the parameters of the Step method so that it uses many more iterations
physicsWorld.Step(1f / 60f, 50, 50);
And I put in some debug code to color the background red if there is any contact between the bodies in the world, but it never fires.
if (physicsWorld.ContactCount > 0)
loadedLevel.levelBackgroundColor = Color.Red;
I've spent about 8 hours on this issue now and I'm getting out of good ideas to what might be the problem here.
So I would be grateful of any reply.