how can i prevent to go down slopes or up hills that are too steep on heightmap terrain? I have a 3d camera that moves on a terrain, it now moves on any place even on big slopes and on hills that are too steep, what can I do?
You should predict where you're going to end up if you attempt to move in a direction, and then figure out if the slope between your current point and your future point is too steep:
if(forward key pressed) {
get location I'll end up at
get the Z of that location
calculate slope using rise/run formula
if(slope is too steep) {
don't move
}
else { move to the future location }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With