0
\$\begingroup\$

I want to know how I can lerp from my current position, to another position, while hugging the terrain. Imagine I'm doing something like surfing, or skateboarding, where I need to follow the rail...etc. I've tried simply projecting from the location down to the plane to get the projection vector, but this will have problems if it's not flat. If it's bumpy, or if there are slopes, there are problems. Any ideas?

This is what I have been doing: enter image description here

enter image description here

But this only works when the surface is flat. I call Set Normal in begin play.

I also made a little video which might be helpful: https://www.youtube.com/watch?v=ptOBBt589sk

\$\endgroup\$
6
  • \$\begingroup\$ What problems do you observe, with what code? Edit your question to show us these details to ensure you get answers that accurately address those problems. \$\endgroup\$
    – DMGregory
    Jul 15 at 0:45
  • \$\begingroup\$ There is no code. I'm wondering what I would need to perform to get something to follow slopes and curves of terrain. I was projecting a vector along a plane, but the problem with this method is that it only works on flat surfaces. \$\endgroup\$ Jul 15 at 0:47
  • \$\begingroup\$ Presumably you considered using a raycast or spherecast to project onto a non-planar surface? \$\endgroup\$
    – DMGregory
    Jul 15 at 0:50
  • \$\begingroup\$ A raycast wouldn't give me a vector though, it just returns a bunch of information about the point that was hit. \$\endgroup\$ Jul 15 at 1:22
  • \$\begingroup\$ Hint: the point that was hit can give you a vector. 😉 (A point is just a vector offset from the origin, after all) Try editing your question to show what you get from a raycast in your engine or framework, and we can show you how to use that to determine a the position vector for your surfing interpolation. \$\endgroup\$
    – DMGregory
    Jul 15 at 1:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.