0
\$\begingroup\$

I have a bicycle with suspension and need to find the contact point of the wheel on the "road". If the front fork was pointing straight down, it would be as easy as doing a raycast down the fork, with the raycast's length limited to the shock travel length + wheel radius. If there is a hit point, the wheel's position is the hit point - wheel radius up the fork from the hit point.

With the fork angled this same approach leads to a part of the wheel being under the detected surface. Then the wheel is moved up by the wheel radius along the fork direction. The green line is the ray cast. enter image description here

Keep in mind that I do not know if the raycast will return anything nor that the normal of the detected surface will be in a set orientation. The blue circle shows where the wheel should be in this case.

The only way I can think to solve this is to do the following. Move down the fork to the maximum extension. Then create multiple points in a circle, a wheel radius away. If I then raycast from the top of shock to each one of these points. The shortest one should be the real contact point. The amount of raycasts will affect the accuracy.

enter image description here

It just feels like there should be a better way to do this.

In summary, I need to find a point that is a radius away from a surface. But this point is constrained to move along an axis (the fork direction).

\$\endgroup\$
2
  • \$\begingroup\$ Have you tried a circlecast (ie. a swept circle collision check) rather than a raycast? Depending on what tech stack you're using, there may be existing methods you can call for this. Or you may have to write your own - searching "swept circle vs [shape]" should get you examples of the intersection functions you need for each type of geometry you need to handle. \$\endgroup\$
    – DMGregory
    Oct 20, 2022 at 17:04
  • \$\begingroup\$ @DMGregory I see I can use SphereCast in Unity that might be a good option. But The Swept Circle Algorithm looks extremely interesting. I am going to go read up on that. \$\endgroup\$ Oct 23, 2022 at 18:49

0

You must log in to answer this question.

Browse other questions tagged .