limit fov range

This commit is contained in:
Cat Flynn 2022-09-05 20:09:34 +01:00
parent 2a4c3b4c88
commit 8ccd003b00
1 changed files with 13 additions and 3 deletions

View File

@ -5,9 +5,10 @@ public class OrbitCamera : Spatial
{
[Export]
private float _lookSensitivity = 200f;
[Export]
private float _zoomSensitivity = 10f;
[Export]
private Vector2 _fovRange = new Vector2(10, 60);
[Export]
private NodePath _cameraPath;
@ -65,9 +66,18 @@ public class OrbitCamera : Spatial
}
}
private void Zoom(float amount)
private void Zoom(int dir)
{
Camera.Fov += amount * _zoomSensitivity / Camera.Fov;
if (dir != 1 && dir != -1)
throw new ArgumentException();
var fov = Camera.Fov;
var zoom = _zoomSensitivity / Camera.Fov;
fov += (float)dir * zoom;
fov = Mathf.Clamp(fov, _fovRange.x, _fovRange.y);
Camera.Fov = fov;
}
private void HandleMouseMovement(InputEventMouseMotion mouseMotion)