BUG * BetterCharacterControl bounces off slopes

You can look at the video in this thread to see the problem. Watch to the end where I step on the steep slopes.


The issue is the control bounces off any slope when you stop applying force. While moving the control is fine. The steeper the slope the higher the bounce. The bounce isn’t effected by player weight , gravity , capsule shape etc. Changing these things has no effect.

I’m not a physicist but just imagine this. You push a marble up a slope using your fingers. If you stop pushing the marble it won’t bounce into the air it will simply stop. There is clearly a problem in the final tick of the physics engine. Hopefully one of you physics guys can figure it out.

I really hope this gets fixed before the 3.1 release or at least addressed.

The core problem is the way bipdeald beings (aka humans work)
Basically the friction of legs is 0 in the direction you go, and pretty high in any other.
Now if you rapidly stop going, you do absorb the excess energy with your muscles dynamically.
However the physicengine has a pretty hard character so the excess energy is redirected into the air.

Try different settings for gravity and restitution (+ a shitton of game specific logic)
Eg in my game I use 40g directly after detecting that is on ground & player stopped walking.


I found the same bug in the physics system of the universe as well:


now if he where to go half way up the ramp and press the brakes he wouldn’t bounce straight up in the air :slight_smile:

I’ve played with all the settings. The only thing that works is shrinking down your scene then using very little force to push. I even set the gravity and weight to 10,000+ kilos. With those settings it shouldn’t ever leave the ground with out some crazy force.

@normen The best way I could put it is imagine if I where running up a hill and I was halted suddenly by my foot becoming stuck in a bear trap. I would fall forward in the direction I was running. The same would happen if I rode a bicycle up a hill then stopped the wheels by braking. The bike (with me on it) would tumble forward.

What is happening in the physics engine is the object going up the slope is bouncing straight up in the air. If the object continued to roll up the hill a little after I stopped applying force that would make perfect sense. The issue is the object isn’t continuing in the direction it was headed when the force is stopped.

Like @Empire_Phoenix was saying the force is being redirected to the air which seems like an odd choice. Perhaps there is a way to stop this behavior because frankly it’s not natural :sunny:

According to your logic he wouldn’t go further up than the top of the ramp either. And then theres the weight of your object. In the code you link you create a 2 meter high object with only 1 kg of mass… Thats basically a huge beach ball - actually its even lighter than air. That will certainly bounce very high up if you accelerate it towards any kind of slope or bump.

@normen Ignore that 1kg of mass. I was playing with the values when I copied that. I’m not sure what you mean by he would’t go further than the top of ramp. If there is enough force behind him it would push him over if his bike was suddenly stopped. I said the bike would roll forward still if the motion stopped.

Even if it was a beach ball if I pushed it up a 30 degree slope then stopped pushing the ball would continue to roll up the slope until all of the force was gone it wouldn’t just bounce straight up in the air.

The foot in the bear trap analogy is my best example because in my game when you release the stop key the not only is the force stopped but the friction is turned up. I turn up the friction to keep the player from sliding back down slopes.

With the character the horizontal motion is damped, else you’d apply a speed and it would continue moving around which is not what people expect when they use a character (you can actually set the damping to zero though). So if you stop moving halfway on a ramp the only thing thats left is the vertical speed which was applied by moving up the ramp. This is only countered by the gravity so it does continue to move up, just like the motorbike didn’t stop moving upwards when the ramp ended, it continued to move up after it until the gravity countered that effect and it started to move back towards the ground.

@normen Thanks , the dampening was the issue. I changed it to set the friction low dampening high while in motion then I scaled down the dampening while not in motion and it worked fine.

Didn’t read anything after the universe bug.

I found that my character hung in the air when walking down slopes - I just applied an impulse pushing him down at all times. Is this not a good solution?

Maybe you also made a 1kg 2m beach ball.

Actually the mass really doesn’t matter here, as far as my testing goes you can define mass as anything you want and nothing will change (unless you start to run into float precission errors), a ball with a mass of 0.0001 will behave exactly the same as one with a mass of 1000.0. It is only relevant for collision between dynamic objects in which case the ratio between the mass determines the result, a 10.0 mass ball colliding with a 1.0 ball will look to same as a 0.1 and 0.01 mass ball.

The problem with rigidbodys and characters is that the character usually isn’t a rigidbody, for example a person jumping over a 1m high wall isn’t going to move his center of mass up by 1 meter to get over the wall, he will effectively shift his weight barely moving the center of mass (legs go up, upper body comes down). That is why jumping by applying an upwards impulse usually looks all kinds of wrong.
Another case is a person running up stairs, he will see the end of the stairs and start shifting his center of mass in order to avoid acting like the bike in the video above (just imagine the bike scanning the area infront of it and adjusting the springs of the wheels precisely to the slope, the driver wouldn’t even notice there was a bump).
Also thats the reason why it’s super awkward whenever you are moving up a stair and expect one more step that isn’t there.

Conclusion: You are simulating a person with a capsule, and a person isn’t a capsule so you’ll have to apply all kinds of hacks to make that capsule behave somewhat like a human would. (The other option, simulating a correct physical human is even more complicated, unfortunately.)

1 Like

@normen Okay , after stepping through the code , performing multiple test and asking the all knowing google I have confirmed this is indeed an issue with the bullet physics character control and not JME. However there is a kinematic character control available now that simulates human walking.

I’m going to test out the kinematic control later and see if it would be feasible to add this control into JME without causing conflict with other parts of the physics.

For now if any one wants a temporary solution here is what I found works. Make a variable that keeps track of if you are in motion. When in motion set your rigid bodies friction to 0 and player control physics dampening to about 0.8 when not in motion set physics dampening to 0 and friction to something real high (depends on your run speed) like 2 or above. This will cause you to stop in your tracks without bouncing.

Optionally you can set the friction higher while in motion which will prevent you from climbing steep slopes.

1 Like