0
\$\begingroup\$

I am trying to make my player slide down a curve (like a water slide) and so far I’ve managed to get the slide direction using the following code

float distance = point.Dot(planeNormal);
return point - distance * planeNormal;
/////
var slideDirection = MainUtils.ProjectOnPlane(Vector3.Down, Core.GetFloorNormal());

This works, but the problem is that sometimes the slide surface tilts. I don’t know if that’s the right word for it, but I hope the image below helps. enter image description here

So, how do I maintain the desired sliding direction (the green line) even in this cases, ignoring the orange directions?

\$\endgroup\$
8
  • 1
    \$\begingroup\$ Very basic breakdown... The object's momentum will make it move along the green line (if its velocity is already along the start of the green line). The orange lines are the direction of forces that will make the object follow the green line (assuming no additional forces are to be added). \$\endgroup\$
    – Blindman67
    Commented Jan 2 at 21:15
  • \$\begingroup\$ My bad I gave that image as an example, I tried to make my problem as visible as possible, but the thing is that I have different slopes, with ups and downs, in any direction, that's why I would rather get the center line that goes across them (or a geodesic line, I guess?) so I can apply that as a velocity. \$\endgroup\$ Commented Jan 3 at 6:38
  • \$\begingroup\$ You say you want to "get the center line", but can you draw the center line (define it as a spine)? \$\endgroup\$
    – Theraot
    Commented Jan 3 at 8:59
  • \$\begingroup\$ Yeah, I made a spline that would mimic the shape of the slope, and tried to get the normal by subtracting the closest point on spline from the next one, but it does not really work. I think the way I get the closest Point is not working, but I'm still playing around with this. I'm open to any suggestions anyway. \$\endgroup\$ Commented Jan 3 at 10:34
  • \$\begingroup\$ Do you always want the object to follow your ideal path or do you need the path to be subjected to physics? \$\endgroup\$
    – Pikalek
    Commented Jan 3 at 21:28

0

You must log in to answer this question.

Browse other questions tagged .