mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
UNIT - added get altitude function with AGL option
This commit is contained in:
parent
498d7e2f66
commit
f9ace54fab
@ -532,7 +532,7 @@ function POSITIONABLE:GetBoundingRadius(mindist)
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Returns the altitude of the POSITIONABLE.
|
||||
--- Returns the altitude above sea level of the POSITIONABLE.
|
||||
-- @param Wrapper.Positionable#POSITIONABLE self
|
||||
-- @return DCS#Distance The altitude of the POSITIONABLE.
|
||||
-- @return #nil The POSITIONABLE is not existing or alive.
|
||||
@ -775,7 +775,7 @@ function POSITIONABLE:GetRelativeVelocity(positionable)
|
||||
end
|
||||
|
||||
|
||||
--- Returns the POSITIONABLE height in meters.
|
||||
--- Returns the POSITIONABLE height above sea level in meters.
|
||||
-- @param Wrapper.Positionable#POSITIONABLE self
|
||||
-- @return DCS#Vec3 The height of the positionable.
|
||||
-- @return #nil The POSITIONABLE is not existing or alive.
|
||||
|
||||
@ -179,8 +179,28 @@ function UNIT:GetDCSObject()
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Returns the unit altitude above sea level in meters.
|
||||
-- @param Wrapper.Unit#UNIT self
|
||||
-- @param #boolean FromGround Measure from the ground or from sea level (ASL). Provide **true** for measuring from the ground (AGL). **false** or **nil** if you measure from sea level.
|
||||
-- @return #number The height of the group or nil if is not existing or alive.
|
||||
function UNIT:GetAltitude(FromGround)
|
||||
|
||||
local DCSUnit = Unit.getByName( self.UnitName )
|
||||
|
||||
if DCSUnit then
|
||||
local altitude = 0
|
||||
local point = DCSUnit.getPoint() --DCS#Vec3
|
||||
altitude = point.y
|
||||
if FromGround then
|
||||
local land = land.getHeight( { x = point.x, y = point.z } ) or 0
|
||||
altitude = altitude - land
|
||||
end
|
||||
return altitude
|
||||
end
|
||||
|
||||
return nil
|
||||
|
||||
end
|
||||
|
||||
--- Respawn the @{Wrapper.Unit} using a (tweaked) template of the parent Group.
|
||||
--
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user