fit : playable with controller

This commit is contained in:
Ferlat Thibaud
2026-06-02 20:09:52 +02:00
parent c71e66fe55
commit bf9a4e64ca
82 changed files with 8723 additions and 1684 deletions
@@ -88,6 +88,12 @@ namespace OctoCore.Components
[Tooltip("Vertical sensitivity (Pitch).")]
public float SensitivityY = 0.1f;
[Tooltip("Gamepad horizontal sensitivity.")]
public float GamepadSensitivityX = 150f;
[Tooltip("Gamepad vertical sensitivity.")]
public float GamepadSensitivityY = 150f;
[Tooltip("Minimum pitch (looking down).")]
public float MinPitch = -80f;
@@ -346,20 +352,26 @@ namespace OctoCore.Components
case PlayerModes.FirstPerson:
if (cam && !_state.IsPaused)
{
Vector2 delta = (_state.IsPaused || !_state.IsFocussed) ? Vector2.zero : _lookInput;
Vector2 delta = (_state.IsPaused || !_state.IsFocussed || !_settings.AllowLook) ? Vector2.zero : _lookInput;
if (_settings.AllowLook)
{
float mouseX = delta.x * _firstPerson.SensitivityX;
float mouseY = delta.y * _firstPerson.SensitivityY * -1;
bool isGamepad = Gamepad.current != null &&
Gamepad.current.rightStick.ReadValue().magnitude > 0.01f;
_state.Yaw += mouseX;
float sensX = isGamepad ? _firstPerson.GamepadSensitivityX : _firstPerson.SensitivityX;
float sensY = isGamepad ? _firstPerson.GamepadSensitivityY : _firstPerson.SensitivityY;
float lookX = isGamepad ? delta.x * sensX * Time.deltaTime : delta.x * sensX;
float lookY = isGamepad ? delta.y * sensY * -1 * Time.deltaTime : delta.y * sensY * -1;
_state.Yaw += lookX;
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 + lookY, _firstPerson.MinPitch, _firstPerson.MaxPitch);
}
if (_state.Driver)