Hey there,
I’m using libGDX for a sidescrolling game.
This is my first libGDX project so far, I like it pretty much(usually used just lwjgl/awt)…
Please try the game first(walking/jumping/climbing).
To me, it feels like the player slides a bit too much. It feels like it’s walking on ice or something.
Alle the collision is done with Box2D
public void tick() {
wasJumping = jumping;
Body body = bodyComponent.getBody();
Vector2 worldCenter = body.getWorldCenter();
if (Gdx.input.isKeyPressed(Input.Keys.A)) {
body.applyLinearImpulse(new Vector2(-1f, 0), worldCenter, true);
dir = 0;
walking = true;
}
if (Gdx.input.isKeyPressed(Input.Keys.D)) {
body.applyLinearImpulse(new Vector2(1f, 0), worldCenter, true);
dir = 1;
walking = true;
}
if ((Gdx.input.isKeyJustPressed(Input.Keys.W) || Gdx.input.isKeyJustPressed(Input.Keys.SPACE)) && !jumping && !falling && !canClimb) {
body.applyLinearImpulse(new Vector2(0, 18f), worldCenter, true);
jumping = true;
}
if (canClimb) {
climbing = true;
if (Gdx.input.isKeyPressed(Input.Keys.W)) {
body.applyLinearImpulse(new Vector2(0, 1.0f), worldCenter, true);
} else if (Math.abs(body.getLinearVelocity().y) > 0.0) {
body.applyLinearImpulse(new Vector2(0, .5f), worldCenter, true);
} else {
climbing = false;
}
}
if (Math.abs(body.getLinearVelocity().x) < 0.4f) {
walking = false;
}
}
Can someone suggest me what to do? I’d like the movement to be bit less slippery.
Hopefully someone knows what I mean haha.