OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Rimak on 29 Aug 2002, 11:07:10
-
Hello ppl,
The problem is:
We have a chopper hovering in the air and soldier standing on the roof of a building.
The question:
How to calculate real distance between these two units? Simply using 'distance' gives incorrect result. Because Y coord (height) of a unit standing on a roof is wrong as if it were standing on the ground. Any solutions?
P.S. When climbing the ladder Y coordinate is correct and shows the real unit height above the ground.
-
Use Pythagoras' theorem. Like so:
+ Heli1
/|
Distance - / | - Vertical distance
/ |
Soldier1 +---+
|
Horizontal distance
Distance^2 = (Vertical Distance)^2 + (Horizontal Distance)^2
; The square of the distance between the two is the square of the horizontal distance plus the square of the vertical distance
_distanceHorizontal = Soldier1 distance Heli1;
_distanceVertical = abs (getPos Soldier1 select 2 - getPos Heli1 select 2);
_distance = sqrt (_distanceHorizontal * _distanceHorizontal + _distanceVertical * _distanceVertical)
Pope Zog
-
It is not so simple. The problem is that i can't get 'real' vertical distance when soldier is standing on the roof of the building. Game reports that the soldier's altitude is ~0 and the real altitude can be 15 or 20.
-
Try placing a gamelogic unit at the position of the soldier and then querying the distance between the gamelogic and the soldier. A gamelogic is allway 0m above ground. Something tells me it wont work but its worth a shot.