The sliding problems is well known. Using the linepick and only apply gravity may solve the problem in some cases, but not ever time, because this may lead to some kind of flipflop state: one frame it's applied, next frame it's not because the linepick reaches the limit only ever second time, or maybe every third, forth etc, which may result in jittering gravity behaviour when standing on a slope.
There is a method that may look like a hack , but it could work well:
Do a linepick against the ground, as described
apply simple gravity only when one of the following conditions are true:
- pickedNX, NY and NZ signal a totally even ground
- pickedNX, NY and NZ signal a steep slope (here you can define the angle that is required to start sliding!)
- nothing was picked, player is free falling.
when pickedNX etc signal there is a flat slope where you don't want the player to slide, do this instead:
(all movement controls are already done here)
store X,Y,Z
apply gravity
updateworld()
store new X,Y,Z
position player at old_x, y ,old_z
There is a method that may look like a hack , but it could work well:
Do a linepick against the ground, as described
apply simple gravity only when one of the following conditions are true:
- pickedNX, NY and NZ signal a totally even ground
- pickedNX, NY and NZ signal a steep slope (here you can define the angle that is required to start sliding!)
- nothing was picked, player is free falling.
when pickedNX etc signal there is a flat slope where you don't want the player to slide, do this instead:
(all movement controls are already done here)
store X,Y,Z
apply gravity
updateworld()
store new X,Y,Z
position player at old_x, y ,old_z