limit fov range
This commit is contained in:
parent
2a4c3b4c88
commit
8ccd003b00
|
@ -5,9 +5,10 @@ public class OrbitCamera : Spatial
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
private float _lookSensitivity = 200f;
|
private float _lookSensitivity = 200f;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
private float _zoomSensitivity = 10f;
|
private float _zoomSensitivity = 10f;
|
||||||
|
[Export]
|
||||||
|
private Vector2 _fovRange = new Vector2(10, 60);
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
private NodePath _cameraPath;
|
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)
|
private void HandleMouseMovement(InputEventMouseMotion mouseMotion)
|
||||||
|
|
Loading…
Reference in New Issue