Author: Pierre MGI
Author Website:

Short description: How to get the same distance info as displayed in rangefinder
Date: 2016-03-03 18:25
Submitted by: Pierre MGI


Comments: (0)
Rating:



 

Rangefinder Distance

by
Pierre MGI


Description
Mimicks the behaviour of the handheld rangefinders to present the distance you are looking at.

Code
[] spawn {
  while {true} do {
    sleep 0.2;
    _ins = lineIntersectsSurfaces [AGLToASL positionCameraToWorld [0,0,0],AGLToASL positionCameraToWorld [0,0,5000],vehicle player,objNull,true,1,"FIRE","NONE"];
    _cursor_distance = if (count _ins > 0) then [{(_ins select 0 select 0) vectorDistance (eyepos player)},{5000}];
    _aim_dist_txt = if (count _ins > 0) then [{str(round _cursor_distance)},{"---"}];
    hintSient format ["%1", _aim_dist_txt];
  };
};

On each framed version
[] spawn {
  ["range_finder", "onEachFrame", {
    _ins = lineIntersectsSurfaces [AGLToASL positionCameraToWorld [0,0,0],AGLToASL positionCameraToWorld [0,0,5000],vehicle player,objNull,true,1,"FIRE","NONE"];
    _cursor_distance = if (count _ins > 0) then [{(_ins select 0 select 0) vectorDistance (eyepos player)},{5000}];
    _aim_dist_txt = if (count _ins > 0) then [{str(round _cursor_distance)},{"---"}];
    hintSilent format ["%1", _aim_dist_txt];
  }] call BIS_fnc_addStackedEventHandler
};


Usage
Debug, unconditional trigger, script





Tags: No tags