mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Attempt aof fixing the placement of spotting scopes on slopes
This commit is contained in:
parent
11dc3bd71a
commit
a12d9dc2fb
@ -27,15 +27,30 @@ if ((_unit call CBA_fnc_getUnitAnim) select 0 == "stand") then {
|
||||
[{
|
||||
params ["_unit"];
|
||||
|
||||
private ["_direction", "_position", "_spottingScope"];
|
||||
_direction = getDir _unit;
|
||||
_position = (getPosASL _unit) vectorAdd [0.8 * sin(_direction), 0.8 * cos(_direction), 0.02];
|
||||
// prevent collision damage
|
||||
[QEGVAR(common,fixCollision), _unit] call CBA_fnc_localEvent;
|
||||
|
||||
_spottingScope = "ACE_SpottingScopeObject" createVehicle [0, 0, 0];
|
||||
// Check for a place to land the spotting scope
|
||||
private _direction = getDir _unit;
|
||||
private _position = (getPosASL _unit) vectorAdd [0.8 * sin(_direction), 0.8 * cos(_direction), 0];
|
||||
private _vectorUp = [0, 0, 1];
|
||||
private _intersections = lineIntersectsSurfaces [_position vectorAdd [0, 0, 1.5], _position vectorDiff [0, 0, 1.5], _unit, objNull, true, 1, "GEOM", "FIRE"];
|
||||
if (_intersections isEqualTo []) then {
|
||||
TRACE_1("No intersections",_intersections);
|
||||
} else {
|
||||
(_intersections select 0) params ["_touchingPoint", "_surfaceNormal"];
|
||||
_position = _touchingPoint vectorAdd [0, 0, 0.05];
|
||||
_vectorUp = _surfaceNormal;
|
||||
};
|
||||
|
||||
// Create the scope and set its position and orientation
|
||||
private _spottingScope = "ACE_SpottingScopeObject" createVehicle [0, 0, 0];
|
||||
_spottingScope setDir _direction;
|
||||
_spottingScope setPosASL _position;
|
||||
if ((getPosATL _spottingScope select 2) - (getPos _spottingScope select 2) < 1E-5) then {
|
||||
_spottingScope setVectorUp (surfaceNormal (position _spottingScope));
|
||||
};
|
||||
_spottingScope setVectorUp _vectorUp;
|
||||
[QEGVAR(common,fixPosition), _spottingScope, _spottingScope] call CBA_fnc_targetEvent;
|
||||
[QEGVAR(common,fixFloating), _spottingScope, _spottingScope] call CBA_fnc_targetEvent;
|
||||
|
||||
_unit reveal _spottingScope;
|
||||
|
||||
}, [_unit], 1, 0] call CBA_fnc_waitAndExecute;
|
||||
|
Loading…
Reference in New Issue
Block a user