diff --git a/scripts/ai/AIDriveStrategyCombineCourse.lua b/scripts/ai/AIDriveStrategyCombineCourse.lua index 46a5c7d7c..eba484bb6 100644 --- a/scripts/ai/AIDriveStrategyCombineCourse.lua +++ b/scripts/ai/AIDriveStrategyCombineCourse.lua @@ -503,8 +503,7 @@ function AIDriveStrategyCombineCourse:onWaypointPassed(ix, course) if self.state == self.states.UNLOADING_ON_FIELD and self.unloadState == self.states.MAKING_POCKET and self.unloadInPocketReferenceIx then - local _, _, dz = self.course:getWaypointLocalPosition(self.vehicle:getAIDirectionNode(), self.unloadInPocketReferenceIx) - if dz < 15 then + if self.course:getDistanceBetweenVehicleAndWaypoint(self.vehicle, self.unloadInPocketReferenceIx) < 15 then -- we are close enough to the reference waypoint, so stop making the pocket and wait for unload. self:debug('Waiting for unload in the pocket') self.unloadState = self.states.WAITING_FOR_UNLOAD_IN_POCKET