Hello. I’ve two questions about BetterCharacterControl which are possibly related.
1. I’m not sure how to stop it from falling through terrain when falling at high speeds (this is part of the game). The terrain is also physics-controlled.
First, I get my preemptive ‘red flag’ for when the player is about to pass through the ground by casting a ray down, getting the distance, then checking this against the player’s velocity * tpf.
To stop the player, I’ve tried negating the gravity, but I can’t get the numbers right here (player shoots off into space), and using ‘warp’ to move the player, but the player still has the same velocity, meaning it sort of jitters up and down on the spot for a while.
2. How do I stop the player from bouncing on the ground? I can set the restitution on the terrain, but not sure how to do so on the player.
Regarding the first, I don’t know bullet at all but in a general physics sense you would have to apply a reverse impulse to affect velocity directly. It should be -currentVelocity * tpf to negate all velocity. Or just make a negative y velocity if you only want to nullify downward movement.
I actually don’t know how bullet implements impulses so I could be wrong.
For 1) try to get the numbers right
For 2) no there currently isn’t unless you extend the BetterCharacterControl yourself
I plan on encapsulating the movement as well as “slope” settings differently and as restitution and y-movement as well as gravity play into this its not yet clear how the parameters will look.
CollisionResults resultsDn = new CollisionResults();
if (resultsDn.size() > 0)
distance = resultsDn.getClosestCollision().getDistance();
if (playerControl.getVelocity().length() * tpf > distance - playerHeight)
// Reverse the velocity and multiply by the player’s mass x gravity
Normen, with regards to (2), I’ve tried setting restitution to zero on both the player’s rigid body and the terrain, but there’s no difference - the player still bounces. Is there something else I need to consider?