My player drives over a river (water quad). When he hits the terrain (border of river) at a a special y-Value his Velocity is set to -10, so he cannot drive into the terrain. A problem occurs, when he turns arround. He gets "suck" into the terrain!
Is there a way to stop this behaviour? Maybe even a nicer way to measure the border of the river?
if (terrain.getHeight(player.getLocalTranslation()) > 0.8 ){
player.setVelocity(-10f);
}
Additional infos: Terrain is a HeightMap I made in Photoshop...
I think you'll have to reset the players position to the last position where he didnt hit the terrain. So your logic in the next update() loop does not trigger an "collision" and the player can move again.
Also for the bounce effect, consider taking the direction vector of backwards and storing that. Then use it to apply an additional movement, rather than just changing the player's velocity.
For example set player velocity to y=0 and bounce velocity to backwards (whatever backwards is at the moment of impact). Bounce velocity can decay over time, or be overwritten by another collision. That way the bounce velocity won't change when the player turns.