Home   Help Search Login Register  

Author Topic: get the distance of a jump  (Read 488 times)

0 Members and 1 Guest are viewing this topic.

z0s

  • Guest
get the distance of a jump
« on: 02 Sep 2003, 08:13:43 »
I have civilians driving vehicles over a hill, I would like to
know how to have the jump lenght reported.

It would have to report the lenght only once the vehicle
touch the ground.   Then count the distance between the
start and the touchdown.

if u have any suggestion, I have tried a few things but
no luck so far.




Unnamed

  • Guest
Re:get the distance of a jump
« Reply #1 on: 02 Sep 2003, 12:08:51 »
Vektorboson pointed me to his function CalcH, for getting the height above sea level of the terrain:

Code: [Select]
/*---------- CalcH by Vektorboson ----------*/

Private ["_currunit","_result","_sensor"];

_CurrUnit = _This Select 0;

_Result=0.0;

_sensor = "EmptyDetector" createVehicle [0,0,0];
_Sensor SetPos (GetPos _CurrUnit);
_Result=(GetPos _Sensor ) select 2;

DeleteVehicle _Sensor;

_Result

You may be able to use the same principle to get the height of the vehicle as well, and compare it with the height of the terrain, to determine when the vehicle is off the ground?

Offline Spinor

  • Members
  • *
  • I'm a llama!
    • The chain of command
Re:get the distance of a jump
« Reply #2 on: 03 Sep 2003, 15:40:01 »
As the 3rd coordinate of the getPos command gives you the height above
ground, I think you don't need to calculate the absolute height above sea
level.
The tricky thing might be to exactly determine when the vehicle leaves the
ground, because I think even if its on the ground, the z-coordinate is not
exactly zero. You probably need some threshold value like 1 meter
above ground. Try the following (untested):

;------------------------
_vehicle = _this select 0
_threshold = _this select 1

@((getPos _vehicle) > _threshold)
_pos1 = getPos _vehicle

@((getPos _vehicle) < _threshold)
_pos2 = getPos _vehicle

_distance2D = sqrt(((_pos2 select 0) - (_pos1 select 0))^2+((_pos2 select 1) - (_pos1 select 1))^2)
hint format["Jump length: %1", _distance2D]
;---------------------

The script expects the vehicle to be checked and a threshold value (in meters)
that is used to determine the condition of being 'off-ground' as arguments.

First, it waits until the vehicle is above the threshold, then stores the vehicle position.
Then, it waits until the vehicle falls below that threshold, and thus determines
the touchdown positions.

These positions are then used to calculate the distance (here only in 2D) of the jump.

Hope this helps,
Spinor

z0s

  • Guest
Re:get the distance of a jump
« Reply #3 on: 05 Sep 2003, 20:07:12 »
well I got it to work with;

;------------------------
_vehicle = _this select 0
_threshold = _this select 1

@((getPos _vehicle select 2) > 1)
_pos1 = getPos _vehicle

@((getPos _vehicle select 2) < 1)
_pos2 = getPos _vehicle

_distance2D = sqrt(((_pos2 select 0) - (_pos1 select 0))^2+((_pos2 select 1) - (_pos1 select 1))^2)
hint format["Jump length: %1", _distance2D]
;---------------------

ty ,  last post helped a lot.  Only changes were "select 2"


z0s