My problem is that no matter the tuning I don't achieve a fast moving ball. It floats through the air rather than shoots through it.
In the following method I'm creating a ball with the radius of 5
units. Setting the radius to 0.01
yields no difference in the result.
After the creation I apply a LinearImpulse
of ridiculous proportions yet, the ball only floats.
(Also, I'm using the DebugRender. Isn't that supposed to take care of the unit conversions?)
Ball class
public Body createBody(float x, float y, float w, float h) {
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.DynamicBody;
bodyDef.position.set(x,y);
Body body = this.getWorld().createBody(bodyDef);
CircleShape shape = new CircleShape();
shape.setRadius(5);
shape.setPosition(new Vector2(0, 0)); // relative to body position
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = shape;
fixtureDef.density = 3f;
fixtureDef.friction = 0.1f;
fixtureDef.restitution = 0.8f;
body.createFixture(fixtureDef);
shape.dispose();
// note the massive impulse vector
body.applyLinearImpulse(new Vector2(10000, 100000), body.getWorldCenter(), true);
return body;
}
render method in Game class
@Override
public void render(){
Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
debugRenderer.render(world, camera.combined);
// time step, velocityIterations, positionIterations
world.step(1/40.0f, 6, 2);
// scheduler takes care of creating game objects on the fly
}