Adjust spectator camera speed based on height

Slows the camera movement close to the ground as it feels more natural when spectating units up close and such
This commit is contained in:
SilentSpike 2015-08-29 16:03:43 +01:00
parent ffcf0ecf7d
commit 200f44d963

View File

@ -20,14 +20,18 @@
// Kill PFH when not in free cam (or display is closed)
if (isNil QGVAR(camHandler)) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; };
private ["_oldPos","_zoomMod","_mX","_mY","_mZ","_pan","_x","_y","_z"];
private ["_camera","_oldPos","_altMod","_zoomMod","_mX","_mY","_mZ","_pan","_x","_y","_z"];
_oldPos = getPosASL GVAR(camera);
_camera = GVAR(camera);
_oldPos = getPosASL _camera;
// Dolly/Boom amount should be influnced by zoom level (it should really be exponential)
// Dollying should also slow as the camera gets close to the ground
_zoomMod = (GVAR(camZoom) * 0.8) max 1;
_mX = (GVAR(camDolly) select 0) / _zoomMod;
_mY = (GVAR(camDolly) select 1) / _zoomMod;
_altMod = ((((getPos _camera) select 2) * 0.05) max 0.1) min 1;
_mX = (GVAR(camDolly) select 0) * _altMod / _zoomMod;
_mY = (GVAR(camDolly) select 1) * _altMod / _zoomMod;
_mZ = GVAR(camBoom) / _zoomMod;
_pan = (GVAR(camPan) + 360) % 360;
@ -39,6 +43,6 @@ _z = (_oldPos select 2) + _mZ;
GVAR(camPos) = [_x,_y,_z max (getTerrainHeightASL [_x,_y])];
// Update camera position and rotation
GVAR(camera) setPosASL GVAR(camPos);
GVAR(camera) setDir GVAR(camPan);
[GVAR(camera), GVAR(camTilt), 0] call BIS_fnc_setPitchBank;
_camera setPosASL GVAR(camPos);
_camera setDir GVAR(camPan);
[_camera, GVAR(camTilt), 0] call BIS_fnc_setPitchBank;