BetterCharacterController isOnGround test fails on non flat ground

Hi all,

I have a problem mentioned in topic. I just can’t jump when the ground is not exactly flat. I checked that the isOnGround returns false when my character is not on the flat terrain. If you look at the picture attached you can see that in ‘second position’ the slope is hardly spottable but I got isOnGround == false there.

Here is how I initilize the controller:

[java]playerControl = new BetterCharacterControl(1.5f, 4f, 60f);
playerControl.setJumpForce(new Vector3f(10, 300, 10));
playerControl.setGravity(new Vector3f(0, -10, 0));

playerNode = new Node(“the player”);
playerNode.setLocalTranslation(new Vector3f(20, 100, 60));


camNode = new CameraNode(“CamNode”, cam);
camNode.setLocalTranslation(new Vector3f(0, 1.5f, 0));
Quaternion quat = new Quaternion();
quat.lookAt(new Vector3f(0, 0, 1), Vector3f.UNIT_Y);

Have any ideas what I do wrong ?

I’ve had the same issue with it. Honestly it’s not the greatest control, I think it’s still being worked on, but I’ve been sticking with the old CharacterControl. There are too many bugs with the new one.

1 Like

there’s plenty of benefits, but yes it’s still a W.I.P

1 Like

Theres lots of problems with both but I guess more with the old one. Plus the new one isn’t a “black box” and you can easily extend it or change its behavior. Seems like noone cared enough to resolve the issues they have and contribute changes though.


The new charactercontrol has also the problem that is you keep jumping all the time (actually if you jump on the frame where you hit the ground) you’ll jump very high.
But the charactercontrol has also problems. For exemple, if you walk on a thin ground (like a plank. Doesn’t work with a real plan/single layer) you’ll warp constantly (small warp down). This is because of the stepheight which try to move your character bottom as it detects something a bit under it and doesn’t consider the fact that you are actually on the ground (i think).

You also have some problem when the head of the charactercontrol hit a wall which is non vertical (an inverted slop) (you’ll go through the floor).
On the opposite, the bettercharactercontrol doesn’t have a “stepheight” thing, so you’ll keep fying all the time on a non-flat ground. And if you keep walking to a wall while you jump, you’ll get stuck on it.

Both has problems. My main problem is the fact that the “charactercontrol” class is now deprecated, which is a non-sense : even if the bettercharactercontrol was flawless, this is still 2 different approach (kinematic vs physic), non of them is, in essence, “better” - they are just different.

EDIT : and the charactercontrol is NOT a blackbox, i already made some change to be able to change the gravity (but only with the 6 “standard” directions). The fact is, there is a lot of “complex” thing in the CC, but they all have a reason to be there. For exemple the “avoid bounce on a corner” is something that need to be done as a special case, you cannot include this case in something more general. Same happen for the stepheight.

I thought about looking in the code of the controller in quake 3 (open arena), but i didn’t get the energy and the envy to do it.

1 Like

The bullet Character uses a lot of resources, doesn’t apply forces on its surroundings and brings its own irrational fall physics (as opposed to being kinematic which it is not). Thats the main issues the BetterCharacter tries to avoid. The issues it has with jumping could probably be avoided by doing the same dampening it does for sideway forces for upwards forces while its on the ground. The on the ground check could be improved by extending the length of the ray it uses for checking plus removing the ray check when a jump has been initiated. Also always check if you didn’t create a 1,80m high person that weighs 1 kilo or so.

1 Like

It should also be noted in its defence, that it is essentially a collection of convenience methods, and uses all built-in jme functions to become what it is. Every “pre-built” situation like this is not going to fit into every possibility you can throw at it, and inevitably you’re going to have to get your hands dirty and situate it to your requirements.

Lets not forget that game-coding is essentially mathematics all over, and it has a lot of head-scratchers along the way! To quote myself, as I tell my wife once in a while, “if it was easy, it would be boring.”

1 Like

Thanks all for the replies!

I tried to extend the ray in BetterCharacterControl as normen said and it worked. Thanks!
Now I wonder if it is possible to apply ‘maxSlope’ logic to it.

The second thing is that the inertial behaviour as shown in the video is not what I’m looking for.

The jumping here is done only by walking. The physics is damped in x/z plane but in y the forces remain unchanged, so when I stop the character it moves up by the undamped y force.

I’ve also tried the deprecated CharacterControl but the kinematic approach is also not what I really want.
Btw I noticed lower performance with the older controler.

I’ll keep trying to extend the ‘Better’ one and in a meantime I’ll wait for updates.

Increase the gravity of the player maybe?

you can try to use my version of the bettercharactercontrol, but there is still flaws in it:

actually i progressed on that topic and i have a more complex picture which show what should be done on the charactercontrol, but i don’t think you want to implement it anyway.

What you describe in the video is exactly the momentum that the bettercharactercontrol introduce, on purpose. The fact that you can push the bettercharactercontrol (with an explosion for exemple) means a lot of things, and these things include the fact that you “jump” when you arrive at the top of a hill.

1 Like

@jayfella: I’ve tried increasing the gravity but it makes the falling speed not adequate to walking.(looks weird)

@bubuche: I saw your class and it looks like a good approach with that “applyVerticalRecoveryAndMagnet” method. I’ll try to analyze it further. For now it looks weird when I try to fall from a cliff for e.g but much thanks anyway.

Sometimes I feel like want to ‘have my cake and eat it too’ :).