Integration of the octo input system and centralization of player values
This commit is contained in:
@@ -2,27 +2,22 @@ using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using Unheimlich.Data.CameraSettings;
|
||||
using PlayerInput = Unheimlich.Managers.PlayerInputManager;
|
||||
using Unheimlich.Gameplay.Player;
|
||||
using InputManager = Unheimlich.Managers.InputManager;
|
||||
|
||||
namespace Unheimlich.Gameplay.CameraControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles camera panning and player/camera alignment to targets.
|
||||
/// Uses CameraPanSettings ScriptableObject for configuration.
|
||||
/// Supports two modes:
|
||||
/// - Pan: Smooth panning with edge detection (for object inspection)
|
||||
/// - FreeLook: Direct mouse/stick control with angle clamping (for detective board)
|
||||
/// </summary>
|
||||
public class CameraPanController : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private UnityEngine.Camera _camera;
|
||||
[SerializeField] private Transform _playerTransform;
|
||||
|
||||
[Header("Default Settings")]
|
||||
[SerializeField] private CameraPanSettings _defaultSettings;
|
||||
|
||||
private CameraPanSettings _settings;
|
||||
private UnityEngine.Camera _camera;
|
||||
private Transform _playerTransform;
|
||||
|
||||
private Vector2 _originalCameraRotation;
|
||||
private Vector3 _originalCameraLocalPosition;
|
||||
@@ -53,19 +48,34 @@ namespace Unheimlich.Gameplay.CameraControl
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (_camera == null)
|
||||
_camera = UnityEngine.Camera.main;
|
||||
|
||||
if (_playerTransform == null)
|
||||
_playerTransform = transform;
|
||||
// Defer initialization if PlayerController not ready
|
||||
if (PlayerController.Instance != null)
|
||||
{
|
||||
_camera = PlayerController.Instance.PlayerCamera;
|
||||
_playerTransform = PlayerController.Instance.transform;
|
||||
}
|
||||
|
||||
if (_defaultSettings != null)
|
||||
_settings = _defaultSettings;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Retry if not initialized in Awake
|
||||
if (_camera == null && PlayerController.Instance != null)
|
||||
{
|
||||
_camera = PlayerController.Instance.PlayerCamera;
|
||||
_playerTransform = PlayerController.Instance.transform;
|
||||
}
|
||||
|
||||
if (_camera != null)
|
||||
{
|
||||
_originalCameraLocalPosition = _camera.transform.localPosition;
|
||||
_originalCameraLocalRotation = _camera.transform.localEulerAngles;
|
||||
}
|
||||
|
||||
_originalPlayerPosition = _playerTransform.position;
|
||||
if (_playerTransform != null)
|
||||
_originalPlayerPosition = _playerTransform.position;
|
||||
_originalPlayerRotation = _playerTransform.eulerAngles;
|
||||
|
||||
if (_settings == null && _defaultSettings != null)
|
||||
@@ -132,9 +142,6 @@ namespace Unheimlich.Gameplay.CameraControl
|
||||
_needsUpdate = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops camera pan mode and returns to original state.
|
||||
/// </summary>
|
||||
public void StopPan()
|
||||
{
|
||||
IsPanning = false;
|
||||
@@ -165,7 +172,7 @@ namespace Unheimlich.Gameplay.CameraControl
|
||||
float lookY = 0f;
|
||||
bool hasInput = false;
|
||||
|
||||
var lookAction = PlayerInput.GetLookAction();
|
||||
var lookAction = InputManager.GetLookAction();
|
||||
if (lookAction != null)
|
||||
{
|
||||
Vector2 lookInput = lookAction.ReadValue<Vector2>();
|
||||
@@ -199,7 +206,7 @@ namespace Unheimlich.Gameplay.CameraControl
|
||||
float panY = 0f;
|
||||
bool hasInput = false;
|
||||
|
||||
var lookAction = PlayerInput.GetLookAction();
|
||||
var lookAction = InputManager.GetLookAction();
|
||||
if (lookAction != null)
|
||||
{
|
||||
Vector2 lookInput = lookAction.ReadValue<Vector2>();
|
||||
|
||||
Reference in New Issue
Block a user