Jump to content

Recommended Posts

Posted

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.

Blog & Portfolio

 

Current project: moon.chase.star

Posted

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 );
}

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Posted

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.

My job is to make tools you love, with the features you want, and performance you can't live without.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...