From da90826bd086b8eb2555456dcf455301698b2802 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Fri, 12 Oct 2018 20:15:10 +0200 Subject: [PATCH] Fix height problem in workaround solution. --- Moose Development/Moose/Wrapper/Unit.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Moose Development/Moose/Wrapper/Unit.lua b/Moose Development/Moose/Wrapper/Unit.lua index 796238305..a7e2a3fcd 100644 --- a/Moose Development/Moose/Wrapper/Unit.lua +++ b/Moose Development/Moose/Wrapper/Unit.lua @@ -896,7 +896,7 @@ function UNIT:IsShip() end --- Returns true if the UNIT is in the air. --- @param Wrapper.Positionable#UNIT self +-- @param #UNIT self -- @return #boolean true if in the air. -- @return #nil The UNIT is not existing or alive. function UNIT:InAir() @@ -908,11 +908,14 @@ function UNIT:InAir() -- Implementation of workaround. The original code is below. -- This to simulate the landing on buildings. -- local UnitInAir = DCSUnit:inAir() - local UnitInAir = false + local UnitInAir = true local VelocityVec3 = DCSUnit:getVelocity() local Velocity = ( VelocityVec3.x ^ 2 + VelocityVec3.y ^ 2 + VelocityVec3.z ^ 2 ) ^ 0.5 -- in meters / sec - if Velocity < 1 and DCSUnit:getPoint().y <= 30 then - UnitInAir = true + local Coordinate = DCSUnit:getPoint() + local LandHeight = land.getHeight( { x = Coordinate.x, y = Coordinate.z } ) + local Height = Coordinate.y - LandHeight + if Velocity < 1 and Height <= 30 then + UnitInAir = false end self:T3( UnitInAir ) return UnitInAir