I am developing a game in which the user have to hit a high speed ball. To hit the ball I have joined a rectangular body with the actor using revolute joint and enabled its motor, to rotate it with a specified speed(motor speed). Now everything is perfect but sometime when ball`s velocity is high , it is bypassing the rectagular body. Using collision listner i found that collision is happening but ball is not getting reflected after collision. As this is happening only when ball is on a high speed, is it bcoz of density of bodies that are colliding . Or its the motor of revolute joint that is responsible for it ?? Am i missing something here??
Here is the code for both bodies
// method for rectangular body
public Body createRectangleBodyPart(float x, float y, float width,
float height, short groupIndex) {
PolygonShape shape = new PolygonShape();
shape.setAsBox(width*WORLD_TO_BOX, height*WORLD_TO_BOX);
MassData massData = new MassData();
massData.mass = 15;
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.KinematicBody;
bodyDef.position.y = y*WORLD_TO_BOX;
bodyDef.position.x = x*WORLD_TO_BOX;
body = world.createBody(bodyDef);
body.setMassData(massData);
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = shape;
fixtureDef.density = 1;
fixtureDef.friction = 100f;
fixtureDef.restitution = 0.5f;
fixtureDef.filter.groupIndex=groupIndex;
body.createFixture(fixtureDef);
shape.dispose();
return body;
}
// method for ball body
public Body createRoundBodyPart2(float x, float y, float radius,
short groupIndex, float density, int mass) {
CircleShape shape = new CircleShape();
shape.setPosition(new Vector2(0, 0));
shape.setRadius(radius*WORLD_TO_BOX ); // *18
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.DynamicBody;
bodyDef.position.y = y*WORLD_TO_BOX;
bodyDef.position.x = x*WORLD_TO_BOX;
MassData massData = new MassData();
massData.mass = 8;
Body body = world.createBody(bodyDef);
body.setMassData(massData);
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = shape;
fixtureDef.density = 0.5f;
fixtureDef.restitution=0.007f;
fixtureDef.filter.groupIndex = groupIndex;
body.createFixture(fixtureDef);
shape.dispose();
return body;
}