smashthewindow Posted August 29, 2011 Posted August 29, 2011 Is there some engine function to get the slope of the current environment that a controller in on? I'm guessing that this is possible due to the fact that the controller take's a parameter that set's maximun climb angle of the controller at it's constructor. If not, I'm thinking raycasting to solve my problem, but I'm just making sure before I go do something stupid. Quote Blog & Portfolio Current project: moon.chase.star
Canardia Posted August 29, 2011 Posted August 29, 2011 GetTerrainNormal() returns a vector which a terrain triangle is facing, so the slope is orthogonal to that. There's probably some Linear Algebra formula to calculate the orthogonal to a Vec3, perhaps like this: TVec3 GetOrthogonal( const TVec3& v ) // Return a non-zero vector orthogonal to A. { if( 0 == v.X ) return Vec3( 1, 0, 0 ); return Vec3( v.Y, -v.X, 0 ); } Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■
Josh Posted August 29, 2011 Posted August 29, 2011 From terrain.frag: float slope = asin( worldNormal.y ); slope = 90.0 - slope * 57.2957795; You may have to fiddle around with it a little for rads/degrees. Quote Let's build cool stuff and have fun.
smashthewindow Posted August 30, 2011 Author Posted August 30, 2011 Thanks all for the reply. Quote Blog & Portfolio Current project: moon.chase.star
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.