BetterCharacterControl bouncing on stairs

Hey,

I got a little problem, I switched from CharacterControl to BetterCharacterControl. Everything is working good except that, if I try to go on a stair, the player bounces very heavily.
Here are the relevant parts of the code:

playercontrol = new BetterCharacterControl(1.0f, 6f, 8f);
playercontrol.setJumpForce(new Vector3f(0, 1f, 0)); // player cant jmp anyway
playercontrol.setGravity(new Vector3f(0,1f,0));
....
playercontrol.warp(pos);
playermodel.setLocalTranslation(pos);
bulletAppState.getPhysicsSpace().add(playercontrol);

movement is done via playercontrol.setWalkDirection() in onAction just like in TestBetterCharacter.java:

Vector3f modelForwardDir = player.getWorldRotation().mult(Vector3f.UNIT_Z);
walkDirection.set(0, 0, 0);
if (up) {
    walkDirection.addLocal(modelForwardDir.mult(PLAYER_MOVESPEED));
}
playercontrol.setWalkDirection(walkDirection);
playercontrol.setViewDirection(cam.getDirection());

any ideas?

[click here to see the demo][1]
[1]: http://imgur.com/kp6C77K

I don’t know if this will solve the problem, but your gravity vector is pointing up… I think it should be: new Vector3f(0, -1f, 0) or new Vector3f(0, -9.81f, 0); to simulate earth conditions :slight_smile:

yeah, weird thing is no matter whether the gravity is 1f, -1, 800f, -800f or even Float.MAX_VALUE there’s literally no difference.

I just tested with playercontrol.setGravity(new Vector3f(0,-800f,0)); - no difference

Whats the value of PLAYER_MOVESPEED? It could be that you move to fast. To avoid this you could scale the world down and make the movement velocity slower. I’m not entirely sure that that’s the problem though.

Also, your BetterCharacterControl is 6 world units high and weighs only 8kg…

Vector3f modelForwardDir = player.getWorldRotation().mult(Vector3f.UNIT_Z);
walkDirection.set(0, 0, 0);
if (up) {
    walkDirection.addLocal(modelForwardDir.mult(PLAYER_MOVESPEED).setY(0));
}
playercontrol.setWalkDirection(walkDirection);
playercontrol.setViewDirection(cam.getDirection());

try

Its sometimes a good idea to make the the stairs into sloped ramps for your physics model

Thanks for the replies!

walkDirection.addLocal(modelForwardDir.mult(PLAYER_MOVESPEED).setY(0));

doing .setY(0); doesn’t change anything.

I know that the BetterCharcterController only weighs 8kg but setting it to something like 80kg makes the player bounce even more.

PLAYER_MOVESPEED is really high(20) so that’s most-likely the problem. Unfortunately I can’t scale the world down without braking alot stuff

You do realize this is like throwing an 8kg bowling ball at 72 km/h at a stair. I wouldn’t be surprised if it bounced a little :smile:

1 Like