Jump to content

[SOLVED] How to get the terrain normal vector or plane at certain coords?


Recommended Posts

Is there a way to know the terrain normal vector or plane at certain coordinates? I need it to properly calculate friction if the wheels are on a slope.

Edited by Ser
Link to comment
Share on other sites

3 hours ago, Ser said:

Is there a way to know the terrain normal vector or plane at certain coordinates? I need it to properly calculate friction if the wheels are on a slope.

This is the code that KER uses to determine surface slope.  It basically does a raycast down from the vessel's CoM and looks for a terrain hit.  The raycast returns the normal at the hit point (along with some other data).  This requires the surface to actually exist (i.e. it doesn't work for far from the vessel).  If you need it for far from the vessel (or otherwise when no raycast is possible) then you would need to query the PQS directly.  There are various mods that do that but it sounds like the raycast method should be fine for you...

Link to comment
Share on other sites

12 minutes ago, Padishar said:

This is the code that KER uses to determine surface slope.  It basically does a raycast down from the vessel's CoM and looks for a terrain hit.  The raycast returns the normal at the hit point (along with some other data).  This requires the surface to actually exist (i.e. it doesn't work for far from the vessel).  If you need it for far from the vessel (or otherwise when no raycast is possible) then you would need to query the PQS directly.  There are various mods that do that but it sounds like the raycast method should be fine for you...

I was hoping that there's just a function to get that info. Thanks a lot.

Isn't raycasting heavy if done every FixedUpdate()?

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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...