ricardojmendez / UnitySteer

Steering, obstacle avoidance and path following behaviors for the Unity Game Engine
https://numergent.com/tags/unitysteer/
Other
1.2k stars 275 forks source link

Fixed a bug that would incorrectly calculate the intersection points in SteerForSphericalObstacles #58

Open CowboyCoderForever opened 7 years ago

CowboyCoderForever commented 7 years ago

I believe the Pythagorean theorem code should have a subtraction, not an addition. While debug rendering the calculated intersection points, the original code could generate points that were wildly off. Changing the formula now generates the intersection points directly on the radius of the sphere/circle.

This might not have much impact on obstacle avoidance (the original points would indeed steer the vehicle away from the obstacle) but it should allow the vehicles to have a closer tolerance to the obstacle.

CowboyCoderForever commented 7 years ago

Note - the code in the Ray-Sphere intersection method aligns nicely with this page: http://kylehalladay.com/blog/tutorial/math/2013/12/24/Ray-Sphere-Intersection.html