feat: OctoPlayer sensitivity settings for mouse & controller
This commit is contained in:
@@ -82,11 +82,11 @@ namespace OctoCore.Components
|
||||
|
||||
[Header("Settings")]
|
||||
|
||||
[Tooltip("Horizontal sensitivity (Yaw).")]
|
||||
public float SensitivityX = 0.1f;
|
||||
[Tooltip("Mouse sensitivity (Yaw & Pitch).")]
|
||||
public Vector2 MouseSensitivity = new Vector2(.1f, .1f);
|
||||
|
||||
[Tooltip("Vertical sensitivity (Pitch).")]
|
||||
public float SensitivityY = 0.1f;
|
||||
[Tooltip("Controller sensitivity (Yaw & Pitch).")]
|
||||
public Vector2 ControllerSensitivity = new Vector2(140, 140);
|
||||
|
||||
[Tooltip("Minimum pitch (looking down).")]
|
||||
public float MinPitch = -80f;
|
||||
@@ -350,16 +350,18 @@ namespace OctoCore.Components
|
||||
|
||||
if (_settings.AllowLook)
|
||||
{
|
||||
float mouseX = delta.x * _firstPerson.SensitivityX;
|
||||
float mouseY = delta.y * _firstPerson.SensitivityY * -1;
|
||||
bool isController = OctoCore.Instance.Platform.Controller;
|
||||
Vector2 sensitivity = isController ? _firstPerson.ControllerSensitivity * Time.deltaTime : _firstPerson.MouseSensitivity;
|
||||
|
||||
_state.Yaw += mouseX;
|
||||
Vector2 look = delta * new Vector2(sensitivity.x, sensitivity.y * -1);
|
||||
|
||||
_state.Yaw += look.x;
|
||||
float halfRange = _firstPerson.RangeYaw * 0.5f;
|
||||
float deltaYaw = Mathf.DeltaAngle(_firstPerson.ReferenceYaw, _state.Yaw);
|
||||
deltaYaw = Mathf.Clamp(deltaYaw, -halfRange, halfRange);
|
||||
_state.Yaw = _firstPerson.ReferenceYaw + deltaYaw;
|
||||
|
||||
_state.Pitch = Mathf.Clamp(_state.Pitch + mouseY, _firstPerson.MinPitch, _firstPerson.MaxPitch);
|
||||
_state.Pitch = Mathf.Clamp(_state.Pitch + look.y, _firstPerson.MinPitch, _firstPerson.MaxPitch);
|
||||
}
|
||||
|
||||
if (_state.Driver)
|
||||
|
||||
Reference in New Issue
Block a user