Hi.
I have a problem with ragdoll I made recently. The problem is that when ragdoll parts collide with ground they seem to stay in place for a moment. I set friction of ragdoll parts and ground to 0 and problem still occurs. It seems to work better if I set velocity and position iterations to larger values but the parts still appear to be glued to the ground. Is there a solution to that?
I enclose links to my youtube video showing the problem and code where the parts of ragdoll are created.
http://www.youtube.com/watch?v=tBanScU1giE
And joint creation:
I have a problem with ragdoll I made recently. The problem is that when ragdoll parts collide with ground they seem to stay in place for a moment. I set friction of ragdoll parts and ground to 0 and problem still occurs. It seems to work better if I set velocity and position iterations to larger values but the parts still appear to be glued to the ground. Is there a solution to that?
I enclose links to my youtube video showing the problem and code where the parts of ragdoll are created.
http://www.youtube.com/watch?v=tBanScU1giE
Code:
//HEAD
private Body createCircle(Vec2 trans,float radius) {
//Shape definition
CircleShape circleShape=new CircleShape();
circleShape.m_radius=radius*RAT;
//Body definition
BodyDef bodyDef =new BodyDef();
bodyDef.type=BodyType.DYNAMIC;
bodyDef.position.set(position.add(trans.mul(RAT)));
//Create Body
Body circle=world.createBody(bodyDef);
//Create Fixture
FixtureDef fixDef=new FixtureDef();
fixDef.shape=circleShape;
fixDef.density=1f;
fixDef.restitution=0.0f;
fixDef.friction=0.3f;
circle.createFixture(fixDef);
bodies.add(circle);
return circle;
}
//BODY
private Body createBox(Vec2 trans,Vec2 dim) {
PolygonShape shapeDef=new PolygonShape();
shapeDef.setAsBox(dim.x*RAT, dim.y*RAT);
//Body definition
BodyDef bodyDef =new BodyDef();
bodyDef.type=BodyType.DYNAMIC;
bodyDef.position.set(position.add(trans.mul(RAT)));
//Create Body
Body box=world.createBody(bodyDef);
//Create Fixture
FixtureDef fixDef=new FixtureDef();
fixDef.shape=shapeDef;
fixDef.density=1f;
fixDef.restitution=0.0f;
fixDef.friction=0.3f;
fixDef.isSensor=false;
box.createFixture(fixDef);
bodies.add(box);
return box;
}
private Body createCircle(Vec2 trans,float radius) {
//Shape definition
CircleShape circleShape=new CircleShape();
circleShape.m_radius=radius*RAT;
//Body definition
BodyDef bodyDef =new BodyDef();
bodyDef.type=BodyType.DYNAMIC;
bodyDef.position.set(position.add(trans.mul(RAT)));
//Create Body
Body circle=world.createBody(bodyDef);
//Create Fixture
FixtureDef fixDef=new FixtureDef();
fixDef.shape=circleShape;
fixDef.density=1f;
fixDef.restitution=0.0f;
fixDef.friction=0.3f;
circle.createFixture(fixDef);
bodies.add(circle);
return circle;
}
//BODY
private Body createBox(Vec2 trans,Vec2 dim) {
PolygonShape shapeDef=new PolygonShape();
shapeDef.setAsBox(dim.x*RAT, dim.y*RAT);
//Body definition
BodyDef bodyDef =new BodyDef();
bodyDef.type=BodyType.DYNAMIC;
bodyDef.position.set(position.add(trans.mul(RAT)));
//Create Body
Body box=world.createBody(bodyDef);
//Create Fixture
FixtureDef fixDef=new FixtureDef();
fixDef.shape=shapeDef;
fixDef.density=1f;
fixDef.restitution=0.0f;
fixDef.friction=0.3f;
fixDef.isSensor=false;
box.createFixture(fixDef);
bodies.add(box);
return box;
}
And joint creation:
Code:
private RevoluteJoint createJoint(Body bodyA, Body bodyB, Vec2 anchor, Vec2 range) {
RevoluteJointDef jointDef = new RevoluteJointDef();
jointDef.initialize(bodyA, bodyB, anchor);
jointDef.lowerAngle = MathUtils.DEG2RAD*range.x; // -45 degrees
jointDef.upperAngle = MathUtils.DEG2RAD*range.y; // 45 degrees
jointDef.enableLimit = false;
jointDef.enableMotor = true;
jointDef.motorSpeed = 0;
jointDef.maxMotorTorque=0f;
jointDef.enableLimit=true;
jointDef.collideConnected = false;
RevoluteJoint joint = (RevoluteJoint) world.createJoint(jointDef);
return joint;
}
RevoluteJointDef jointDef = new RevoluteJointDef();
jointDef.initialize(bodyA, bodyB, anchor);
jointDef.lowerAngle = MathUtils.DEG2RAD*range.x; // -45 degrees
jointDef.upperAngle = MathUtils.DEG2RAD*range.y; // 45 degrees
jointDef.enableLimit = false;
jointDef.enableMotor = true;
jointDef.motorSpeed = 0;
jointDef.maxMotorTorque=0f;
jointDef.enableLimit=true;
jointDef.collideConnected = false;
RevoluteJoint joint = (RevoluteJoint) world.createJoint(jointDef);
return joint;
}