Simple way of determining slope?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
luvcraft
Posts: 23
Joined: Sun Apr 25, 2004 1:00 am
Location: Albuquerque, NM

Simple way of determining slope?

Post by luvcraft »

So I discovered last night that even if a slope is incredibly steep, as long as it's less than 90 degrees a collision-response-animated node can walk up it just as easily as walking along level ground.

What I would like is for my player character to be able to walk up anything up to a 45 degree incline, and not be able to walk up anything steeper (and, in fact, slide down it if he finds himself on it).

Without using one of the popular physics engines (which I want to avoid to cut down on overhead, and because the "feel" of the game really doesn't need realistic physics) what would be the easiest way to determine the slope of the triangle the player is standing on?

Oh, wait, I think I might've just answered my own question; use the X/Z position of the highest and lowest points of the triangle to determine the slope...

If anyone has a better suggestion, or knows off the top of their head how to calculate the above (saving me the trouble of figuring it out with my tiny brain later), please let me know! :)X
luvcraft
Posts: 23
Joined: Sun Apr 25, 2004 1:00 am
Location: Albuquerque, NM

Post by luvcraft »

woo! talkin' to myself!

Just discovered the getNormal() function for triangles, which will make it a whole lot easier to determine the slope. Yay! Can't wait to go home and try it! :)
Post Reply