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

PredictFuturePosition now checks for Position #56

Open michaelcurtiss opened 7 years ago

michaelcurtiss commented 7 years ago

Both the PredictFuturePosition and PredictFutureDesiredPosition should check for the Position property instead of the Transform.position property, so as to account for the DetectableObject's Center offset.

The biggest bug I've found regarding the previous implementation is in regards to the SteerForSphericalObstacles script, which uses the return value of PredictFutureDesiredPosition() to construct a movement vector to work with. This movement vector will be inaccurate since in the steering behaviors I've seen, the DesiredVelocity is being applied with the vehicle's Center property in mind (e.g. SteerForPathSimplified). That is, DesiredVelocity goes from detectableObject.Position to a future detectableObject.Position, but the constructed movement vectory in SteerForSphericalObstacles was going from dectectableObect.Position to a future transform.Position, an inaccurate move vector resulting in inaccurate collision checks.

However, I haven't fully explored all calls to the PredictFuturePosition() functions, so it might create problems somewhere...