In my LibGDX project I am using Box2D for physics. When I try to make two bodies with no friction (0.0f), it still looks like they have friction when they move against each other. One body is static, rotated 45 degrees and the other one is dynamic. What am I missing?
The world is set with a gravity of 9.8 m/s and the pixels per meter (PPM) is 32. What I want is the two bodies to be totally frictionless. In my example code the second body falls onto the first. What I would expect happen when the bodies have no friction is that the second object slides off. What happens though is that the second object instead stops and "drags" along the first object.
Here's the code:
Body b1, b2;
BodyDef def1 = new BodyDef();
PolygonShape shape1 = new PolygonShape();
FixtureDef fDef1 = new FixtureDef();
def1.type = BodyType.StaticBody;
b1 = world.createBody(def1);
shape1.setAsBox(64 / 2 / PPM, 32 / 2 / PPM);
b1.setTransform(20 / PPM, 0, (float)Math.toRadians(60.0));
fDef1.shape = shape1;
fDef1.friction = 0.0f;
fDef1.density = 1.0f;
b1.createFixture(fDef1);
shape1.dispose();
BodyDef def2 = new BodyDef();
PolygonShape shape2 = new PolygonShape();
FixtureDef fDef2 = new FixtureDef();
def2.type = BodyType.DynamicBody;
b2 = world.createBody(def2);
shape1.setAsBox(32 / 2 / PPM, 32 / 2 / PPM);
b2.setTransform(0, 100 / PPM, (float)Math.toRadians(60.0));
fDef2.shape = shape2;
fDef2.friction = 0.0f;
fDef2.density = 1.0f;
b2.createFixture(fDef2);
shape2.dispose();