diff --git a/addons/spectator/functions/fnc_cam.sqf b/addons/spectator/functions/fnc_cam.sqf index 4baf3aee55..28cb4c54f4 100644 --- a/addons/spectator/functions/fnc_cam.sqf +++ b/addons/spectator/functions/fnc_cam.sqf @@ -39,7 +39,7 @@ if (_init) then { // Follow camera related GVAR(camDistance) = 0; - GVAR(camDistanceTemp) = 0; + GVAR(camDistanceTrue) = 0; GVAR(camYaw) = 0; GVAR(camPitch) = 0; @@ -133,7 +133,7 @@ if (_init) then { GVAR(camHasTarget) = nil; GVAR(camTargetInVehicle) = nil; GVAR(camDistance) = nil; - GVAR(camDistanceTemp) = nil; + GVAR(camDistanceTrue) = nil; GVAR(camYaw) = nil; GVAR(camPitch) = nil; GVAR(camSlow) = nil; diff --git a/addons/spectator/functions/fnc_cam_prepareTarget.sqf b/addons/spectator/functions/fnc_cam_prepareTarget.sqf index abdce831b4..81bec1504e 100644 --- a/addons/spectator/functions/fnc_cam_prepareTarget.sqf +++ b/addons/spectator/functions/fnc_cam_prepareTarget.sqf @@ -18,20 +18,24 @@ #include "script_component.hpp" private _focus = vehicle (param [0, objNull, [objNull]]); +TRACE_1("cam_prepareTarget",_focus); if !(isNull _focus) then { - // Interpolate zoom + // Zooming takes place smoothly over multiple frames + // _zoom is target set by user, _zoomTrue is actual value each frame private _zoom = [0, GVAR(camDistance)] select (GVAR(camMode) == MODE_FOLLOW); - private _zoomTemp = GVAR(camDistanceTemp); + private _zoomTrue = GVAR(camDistanceTrue); - if (_zoomTemp != _zoom) then { - _zoomTemp = [_zoomTemp, _zoom, 10, GVAR(camDeltaTime)] call BIS_fnc_lerp; - GVAR(camDistanceTemp) = _zoomTemp; + // Interpolate zoom each frame until desired zoom is reached + if (_zoomTrue != _zoom) then { + _zoomTrue = (_zoomTrue * (1 - GVAR(camDeltaTime) * 10)) + (_zoom * GVAR(camDeltaTime) * 10); + GVAR(camDistanceTrue) = _zoomTrue; + TRACE_2("new zoom",GVAR(camDeltaTime),_zoomTrue); }; // The distance at which to place camera from the focus pivot private _bbd = [_focus] call BIS_fnc_getObjectBBD; - private _distance = (_bbd select 1) + _zoomTemp; + private _distance = (_bbd select 1) + _zoomTrue; // The pivot on the target vehicle private _isMan = _focus isKindOf "Man";