Player -> Collision Terrain Problem

Hi everyone,

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);              } ```

Thanks really much!

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.

Regards,

snare

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.

I have this method:

``` if (terrain.getHeight(player.getLocalTranslation())  > 0.8 ){            Vector3f actualPosition = new Vector3f();           actualPosition.set(player.getLocalTranslation());           lastPosition.multLocal(2);           lastPosition.subtractLocal(actualPosition);           player.getLocalTranslation().set(lastPosition);                         }         else{                     lastPosition.set(player.getLocalTranslation());      } ```

When I hit the terrain my screen is flickering! how can I just move the player 3 position before ?

Thanks