fix(kobling): ankomst måles fra nærmeste led i sættet — bakker AD med vogn, ender vognen på markøren og traktoren et vognslæb væk (stoppedAway ved Bredal) (v1.47.4.0)

This commit is contained in:
2026-09-28 17:23:12 +02:00
parent b8704f1f95
commit e7b0e5c8f5
2 changed files with 13 additions and 4 deletions
+12 -3
View File
@@ -142,10 +142,19 @@ end
local function vehicleState(adEnv, vehicle, markerId)
local module = stateModule(vehicle)
local wayPoint = adEnv.ADGraphManager:getWayPointById(markerId)
-- nærmeste led i sættet: bakker AD med vogn, er det vognen der ender på markøren, ikke traktoren
-- (in-game 28/9: vognen stod på Bredal, traktoren et vognslæb væk -> "stoppedAway")
local distance = math.huge
if wayPoint ~= nil and vehicle.rootNode ~= nil then
local x, _, z = getWorldTranslation(vehicle.rootNode)
distance = math.sqrt((x - wayPoint.x) ^ 2 + (z - wayPoint.z) ^ 2)
local parts = {vehicle}
if vehicle.getChildVehicles ~= nil then
local ok, children = pcall(vehicle.getChildVehicles, vehicle)
if ok and children ~= nil then parts = children end
end
for _, part in pairs(parts) do
if wayPoint ~= nil and part.rootNode ~= nil then
local x, _, z = getWorldTranslation(part.rootNode)
distance = math.min(distance, math.sqrt((x - wayPoint.x) ^ 2 + (z - wayPoint.z) ^ 2))
end
end
return {
adActive = module ~= nil and module:isActive(),