fit : playable with controller
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using OctoCore.Navigation.Data;
|
||||
using OctoCore.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace OctoCore.Navigation
|
||||
{
|
||||
@@ -19,6 +21,9 @@ namespace OctoCore.Navigation
|
||||
[SerializeField, Tooltip("Optional panel to show/hide (options, credits...)")]
|
||||
private GameObject _optionalPanel;
|
||||
|
||||
[SerializeField] private Button _optionalPanelFirstButton;
|
||||
[SerializeField] private Button _mainPanelDefaultButton;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
// Hide optional panel on start if assigned
|
||||
@@ -71,5 +76,15 @@ namespace OctoCore.Navigation
|
||||
}
|
||||
|
||||
// --- Add your custom button methods below ---
|
||||
|
||||
public void SelectDebugFirstButton()
|
||||
{
|
||||
EventSystem.current.SetSelectedGameObject(_optionalPanelFirstButton.gameObject);
|
||||
}
|
||||
|
||||
public void SelectMainDefaultButton()
|
||||
{
|
||||
EventSystem.current.SetSelectedGameObject(_mainPanelDefaultButton.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user