Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xna prevent to go down slopes or up hills that are too steep

Tags:

c#

xna

3d

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?

like image 752
user1182607 Avatar asked Dec 07 '25 21:12

user1182607


1 Answers

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 }
}
like image 191
ravuya Avatar answered Dec 10 '25 11:12

ravuya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!