Snapshot before project reorganization
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using Unheimlich.Utility;
|
||||
using Unheimlich.Data.CameraSettings;
|
||||
|
||||
namespace Unheimlich.Audio
|
||||
{
|
||||
@@ -61,6 +62,9 @@ namespace Unheimlich.Audio
|
||||
|
||||
[Header("Visual Feedback")]
|
||||
[SerializeField] private ParticleSystem _emitterParticles;
|
||||
|
||||
[Header("Camera Settings")]
|
||||
[SerializeField] private CameraPanSettings _cameraPanSettings;
|
||||
|
||||
private AudioSource _audioSource;
|
||||
private AudioSource _continuousAudioSource;
|
||||
@@ -81,6 +85,11 @@ namespace Unheimlich.Audio
|
||||
/// Used to prevent multiple taps on the same emitter.
|
||||
/// </summary>
|
||||
public bool HasBeenTapped => _hasBeenTapped;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the camera pan settings for this emitter, or null if not set.
|
||||
/// </summary>
|
||||
public CameraPanSettings CameraPanSettings => _cameraPanSettings;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
|
||||
@@ -2,6 +2,15 @@ using UnityEngine;
|
||||
|
||||
namespace Unheimlich.Data.CameraSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Camera pan mode.
|
||||
/// </summary>
|
||||
public enum CameraPanMode
|
||||
{
|
||||
Pan,
|
||||
FreeLook
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Head bob mode for camera pan.
|
||||
/// </summary>
|
||||
@@ -19,6 +28,10 @@ namespace Unheimlich.Data.CameraSettings
|
||||
[CreateAssetMenu(fileName = "CameraPanSettings", menuName = "Unheimlich/Camera/Camera Pan Settings")]
|
||||
public class CameraPanSettings : ScriptableObject
|
||||
{
|
||||
[Header("Pan Mode")]
|
||||
[Tooltip("Pan: Smooth edge-based panning for object inspection | FreeLook: Direct mouse/stick control for detective board")]
|
||||
public CameraPanMode PanMode = CameraPanMode.Pan;
|
||||
|
||||
[Header("Camera Pan")]
|
||||
[Tooltip("Camera pan speed when moving the cursor/look stick")]
|
||||
public float PanSpeed = 2f;
|
||||
@@ -27,8 +40,11 @@ namespace Unheimlich.Data.CameraSettings
|
||||
[Range(0f, 0.5f)]
|
||||
public float PanBorderSize = 0.1f;
|
||||
|
||||
[Tooltip("Maximum angle the camera can pan from center")]
|
||||
public float MaxPanAngle = 15f;
|
||||
[Tooltip("Maximum horizontal angle the camera can pan from center (left/right)")]
|
||||
public float MaxPanAngleX = 15f;
|
||||
|
||||
[Tooltip("Maximum vertical angle the camera can pan from center (up/down)")]
|
||||
public float MaxPanAngleY = 15f;
|
||||
|
||||
[Header("Recentering")]
|
||||
[Tooltip("Enable automatic return to center when idle")]
|
||||
@@ -47,6 +63,9 @@ namespace Unheimlich.Data.CameraSettings
|
||||
[Tooltip("Threshold for alignment completion")]
|
||||
public float AlignmentThreshold = 0.5f;
|
||||
|
||||
[Tooltip("Fixed distance from the player to the target when aligning (in meters)")]
|
||||
public float FixedDistanceFromTarget = 1.5f;
|
||||
|
||||
[Header("Head Bob Control")]
|
||||
[Tooltip("Head bob mode: Normal (default behavior), Idle (force subtle breathing), Disabled (no movement)")]
|
||||
public HeadBobMode HeadBobMode = HeadBobMode.Idle;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using Unheimlich.Data.Dialogues;
|
||||
|
||||
[CustomEditor(typeof(DialogueConversation))]
|
||||
@@ -99,7 +98,7 @@ public class DialogueConversationEditor : Editor
|
||||
string path = AssetDatabase.GetAssetPath(conversation);
|
||||
string directory = System.IO.Path.GetDirectoryName(path);
|
||||
|
||||
DialogueNode newNode = ScriptableObject.CreateInstance<DialogueNode>();
|
||||
DialogueNode newNode = CreateInstance<DialogueNode>();
|
||||
newNode.name = $"Node_{conversation.DialogueNodes.Count + 1}";
|
||||
|
||||
string nodePath = AssetDatabase.GenerateUniqueAssetPath($"{directory}/{newNode.name}.asset");
|
||||
|
||||
@@ -9,6 +9,9 @@ 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
|
||||
{
|
||||
@@ -16,8 +19,10 @@ namespace Unheimlich.Gameplay.CameraControl
|
||||
[SerializeField] private UnityEngine.Camera _camera;
|
||||
[SerializeField] private Transform _playerTransform;
|
||||
|
||||
[Header("Settings")]
|
||||
[SerializeField] private CameraPanSettings _settings;
|
||||
[Header("Default Settings")]
|
||||
[SerializeField] private CameraPanSettings _defaultSettings;
|
||||
|
||||
private CameraPanSettings _settings;
|
||||
|
||||
private Vector2 _originalCameraRotation;
|
||||
private Vector3 _originalCameraLocalPosition;
|
||||
@@ -28,7 +33,17 @@ namespace Unheimlich.Gameplay.CameraControl
|
||||
private Coroutine _returnCoroutine;
|
||||
private float _timeSinceLastInput;
|
||||
|
||||
private float _targetYaw;
|
||||
private float _targetPitch;
|
||||
private float _currentYaw;
|
||||
private float _currentPitch;
|
||||
private float _lerpSpeed;
|
||||
private bool _needsUpdate;
|
||||
private CameraPanMode _mode = CameraPanMode.Pan;
|
||||
private Vector2 _lastMousePosition;
|
||||
|
||||
public bool IsPanning { get; private set; }
|
||||
public CameraPanMode Mode => _mode;
|
||||
|
||||
public CameraPanSettings Settings
|
||||
{
|
||||
@@ -52,10 +67,39 @@ namespace Unheimlich.Gameplay.CameraControl
|
||||
|
||||
_originalPlayerPosition = _playerTransform.position;
|
||||
_originalPlayerRotation = _playerTransform.eulerAngles;
|
||||
|
||||
if (_settings == null && _defaultSettings != null)
|
||||
_settings = _defaultSettings;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (IsPanning && _needsUpdate)
|
||||
{
|
||||
if (_mode == CameraPanMode.FreeLook)
|
||||
{
|
||||
float normalizedYaw = Mathf.Repeat(_currentYaw, 360f);
|
||||
float normalizedPitch = _currentPitch;
|
||||
|
||||
_playerTransform.eulerAngles = new Vector3(0f, normalizedYaw, 0f);
|
||||
_camera.transform.localEulerAngles = new Vector3(normalizedPitch, 0f, 0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentYaw = Mathf.LerpAngle(_currentYaw, _targetYaw, Time.deltaTime * _lerpSpeed);
|
||||
_currentPitch = Mathf.LerpAngle(_currentPitch, _targetPitch, Time.deltaTime * _lerpSpeed);
|
||||
|
||||
float normalizedYaw = Mathf.Repeat(_currentYaw, 360f);
|
||||
float normalizedPitch = _currentPitch;
|
||||
|
||||
_playerTransform.eulerAngles = new Vector3(0f, normalizedYaw, 0f);
|
||||
_camera.transform.localEulerAngles = new Vector3(normalizedPitch, 0f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts camera pan mode.
|
||||
/// Starts camera pan mode. The mode (Pan or FreeLook) is determined by the current settings.
|
||||
/// </summary>
|
||||
public void StartPan()
|
||||
{
|
||||
@@ -66,13 +110,26 @@ namespace Unheimlich.Gameplay.CameraControl
|
||||
}
|
||||
|
||||
IsPanning = true;
|
||||
_mode = _settings.PanMode;
|
||||
_timeSinceLastInput = 0f;
|
||||
|
||||
if (Mouse.current != null)
|
||||
_lastMousePosition = Mouse.current.position.ReadValue();
|
||||
|
||||
float currentPitch = _camera.transform.localEulerAngles.x;
|
||||
if (currentPitch > 180f)
|
||||
currentPitch -= 360f;
|
||||
|
||||
_originalCameraRotation = new Vector2(_playerTransform.eulerAngles.y, currentPitch);
|
||||
float currentYaw = _playerTransform.eulerAngles.y;
|
||||
if (currentYaw > 180f)
|
||||
currentYaw -= 360f;
|
||||
|
||||
_originalCameraRotation = new Vector2(currentYaw, currentPitch);
|
||||
_currentYaw = currentYaw;
|
||||
_currentPitch = currentPitch;
|
||||
_targetYaw = currentYaw;
|
||||
_targetPitch = currentPitch;
|
||||
_needsUpdate = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -88,6 +145,52 @@ namespace Unheimlich.Gameplay.CameraControl
|
||||
/// Call this from Update when pan is active.
|
||||
/// </summary>
|
||||
public void UpdatePan()
|
||||
{
|
||||
if (!IsPanning || _camera == null || _settings == null)
|
||||
return;
|
||||
|
||||
if (_mode == CameraPanMode.FreeLook)
|
||||
{
|
||||
UpdateFreeLook();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdatePanMode();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateFreeLook()
|
||||
{
|
||||
float lookX = 0f;
|
||||
float lookY = 0f;
|
||||
bool hasInput = false;
|
||||
|
||||
var lookAction = PlayerInput.GetLookAction();
|
||||
if (lookAction != null)
|
||||
{
|
||||
Vector2 lookInput = lookAction.ReadValue<Vector2>();
|
||||
if (lookInput.sqrMagnitude > 0.01f)
|
||||
{
|
||||
lookX = lookInput.x;
|
||||
lookY = lookInput.y;
|
||||
hasInput = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasInput)
|
||||
{
|
||||
float sensitivity = _settings.PanSpeed * 0.1f;
|
||||
_currentYaw += lookX * sensitivity;
|
||||
_currentPitch -= lookY * sensitivity;
|
||||
|
||||
_currentYaw = Mathf.Clamp(_currentYaw, _originalCameraRotation.x - _settings.MaxPanAngleX, _originalCameraRotation.x + _settings.MaxPanAngleX);
|
||||
_currentPitch = Mathf.Clamp(_currentPitch, _originalCameraRotation.y - _settings.MaxPanAngleY, _originalCameraRotation.y + _settings.MaxPanAngleY);
|
||||
|
||||
_needsUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePanMode()
|
||||
{
|
||||
if (!IsPanning || _camera == null || _settings == null)
|
||||
return;
|
||||
@@ -111,31 +214,38 @@ namespace Unheimlich.Gameplay.CameraControl
|
||||
if (!hasInput && Mouse.current != null)
|
||||
{
|
||||
Vector2 mousePos = Mouse.current.position.ReadValue();
|
||||
float screenWidth = Screen.width;
|
||||
float screenHeight = Screen.height;
|
||||
|
||||
float borderPixels = _settings.PanBorderSize * Mathf.Min(screenWidth, screenHeight);
|
||||
bool mouseHasMoved = Vector2.Distance(mousePos, _lastMousePosition) > 0.1f;
|
||||
_lastMousePosition = mousePos;
|
||||
|
||||
if (mousePos.x < borderPixels)
|
||||
if (mouseHasMoved)
|
||||
{
|
||||
panX = -(borderPixels - mousePos.x) / borderPixels;
|
||||
hasInput = true;
|
||||
}
|
||||
else if (mousePos.x > screenWidth - borderPixels)
|
||||
{
|
||||
panX = (mousePos.x - (screenWidth - borderPixels)) / borderPixels;
|
||||
hasInput = true;
|
||||
}
|
||||
|
||||
if (mousePos.y < borderPixels)
|
||||
{
|
||||
panY = -(borderPixels - mousePos.y) / borderPixels;
|
||||
hasInput = true;
|
||||
}
|
||||
else if (mousePos.y > screenHeight - borderPixels)
|
||||
{
|
||||
panY = (mousePos.y - (screenHeight - borderPixels)) / borderPixels;
|
||||
hasInput = true;
|
||||
float screenWidth = Screen.width;
|
||||
float screenHeight = Screen.height;
|
||||
|
||||
float borderPixels = _settings.PanBorderSize * Mathf.Min(screenWidth, screenHeight);
|
||||
|
||||
if (mousePos.x < borderPixels)
|
||||
{
|
||||
panX = -(borderPixels - mousePos.x) / borderPixels;
|
||||
hasInput = true;
|
||||
}
|
||||
else if (mousePos.x > screenWidth - borderPixels)
|
||||
{
|
||||
panX = (mousePos.x - (screenWidth - borderPixels)) / borderPixels;
|
||||
hasInput = true;
|
||||
}
|
||||
|
||||
if (mousePos.y < borderPixels)
|
||||
{
|
||||
panY = -(borderPixels - mousePos.y) / borderPixels;
|
||||
hasInput = true;
|
||||
}
|
||||
else if (mousePos.y > screenHeight - borderPixels)
|
||||
{
|
||||
panY = (mousePos.y - (screenHeight - borderPixels)) / borderPixels;
|
||||
hasInput = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,48 +258,39 @@ namespace Unheimlich.Gameplay.CameraControl
|
||||
_timeSinceLastInput += Time.deltaTime;
|
||||
}
|
||||
|
||||
float currentYaw = _playerTransform.eulerAngles.y;
|
||||
float currentPitch = _camera.transform.localEulerAngles.x;
|
||||
if (currentPitch > 180f)
|
||||
currentPitch -= 360f;
|
||||
|
||||
float targetYaw;
|
||||
float targetPitch;
|
||||
float lerpSpeed;
|
||||
|
||||
bool shouldRecenter = _settings.EnableRecentering && _timeSinceLastInput >= _settings.RecenterDelay;
|
||||
|
||||
if (hasInput)
|
||||
{
|
||||
targetYaw = _originalCameraRotation.x + panX * _settings.MaxPanAngle;
|
||||
targetPitch = _originalCameraRotation.y - panY * _settings.MaxPanAngle;
|
||||
targetYaw = Mathf.Clamp(targetYaw, _originalCameraRotation.x - _settings.MaxPanAngle, _originalCameraRotation.x + _settings.MaxPanAngle);
|
||||
targetPitch = Mathf.Clamp(targetPitch, _originalCameraRotation.y - _settings.MaxPanAngle, _originalCameraRotation.y + _settings.MaxPanAngle);
|
||||
lerpSpeed = _settings.PanSpeed;
|
||||
_targetYaw = _originalCameraRotation.x + panX * _settings.MaxPanAngleX;
|
||||
_targetPitch = _originalCameraRotation.y - panY * _settings.MaxPanAngleY;
|
||||
_targetYaw = Mathf.Clamp(_targetYaw, _originalCameraRotation.x - _settings.MaxPanAngleX, _originalCameraRotation.x + _settings.MaxPanAngleX);
|
||||
_targetPitch = Mathf.Clamp(_targetPitch, _originalCameraRotation.y - _settings.MaxPanAngleY, _originalCameraRotation.y + _settings.MaxPanAngleY);
|
||||
_lerpSpeed = _settings.PanSpeed;
|
||||
_needsUpdate = true;
|
||||
}
|
||||
else if (shouldRecenter)
|
||||
{
|
||||
targetYaw = _originalCameraRotation.x;
|
||||
targetPitch = _originalCameraRotation.y;
|
||||
lerpSpeed = _settings.RecenterSpeed;
|
||||
_targetYaw = _originalCameraRotation.x;
|
||||
_targetPitch = _originalCameraRotation.y;
|
||||
_lerpSpeed = _settings.RecenterSpeed;
|
||||
_needsUpdate = true;
|
||||
}
|
||||
else
|
||||
else if (_needsUpdate)
|
||||
{
|
||||
targetYaw = currentYaw;
|
||||
targetPitch = currentPitch;
|
||||
lerpSpeed = 0f;
|
||||
float yawDiff = Mathf.Abs(Mathf.DeltaAngle(_currentYaw, _targetYaw));
|
||||
float pitchDiff = Mathf.Abs(Mathf.DeltaAngle(_currentPitch, _targetPitch));
|
||||
|
||||
if (yawDiff < 0.01f && pitchDiff < 0.01f)
|
||||
{
|
||||
_needsUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
float newYaw = Mathf.LerpAngle(currentYaw, targetYaw, Time.deltaTime * lerpSpeed);
|
||||
float newPitch = Mathf.LerpAngle(currentPitch, targetPitch, Time.deltaTime * lerpSpeed);
|
||||
|
||||
_playerTransform.eulerAngles = new Vector3(0f, newYaw, 0f);
|
||||
_camera.transform.localEulerAngles = new Vector3(newPitch, 0f, 0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aligns the player and camera to the target object.
|
||||
/// - Player moves along target's local X axis to align with target center
|
||||
/// - Player moves to a fixed distance in front of the target
|
||||
/// - Player rotates to face the target
|
||||
/// - Camera pitch adjusts to look at target center
|
||||
/// </summary>
|
||||
@@ -259,6 +360,10 @@ namespace Unheimlich.Gameplay.CameraControl
|
||||
if (startPitch > 180f)
|
||||
startPitch -= 360f;
|
||||
|
||||
Vector3 targetForward = target.forward;
|
||||
Vector3 targetPlayerPos = targetCenter - targetForward * _settings.FixedDistanceFromTarget;
|
||||
targetPlayerPos.y = startPlayerPos.y;
|
||||
|
||||
float elapsed = 0f;
|
||||
float duration = 1f / _settings.AlignmentSpeed;
|
||||
|
||||
@@ -275,11 +380,6 @@ namespace Unheimlich.Gameplay.CameraControl
|
||||
float targetYaw = targetRotation.eulerAngles.y;
|
||||
float targetPitch = -Mathf.Asin(directionToTarget.y) * Mathf.Rad2Deg;
|
||||
|
||||
Vector3 targetRightAxis = target.right;
|
||||
Vector3 playerToTargetCenter = targetCenter - _playerTransform.position;
|
||||
float offsetAlongTargetRight = Vector3.Dot(playerToTargetCenter, targetRightAxis);
|
||||
Vector3 targetPlayerPos = _playerTransform.position + targetRightAxis * offsetAlongTargetRight;
|
||||
|
||||
Vector3 currentPlayerPos = Vector3.Lerp(startPlayerPos, targetPlayerPos, t);
|
||||
_playerTransform.position = currentPlayerPos;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Unheimlich.Gameplay.Environment
|
||||
InteractionText = IsOpen ? "Close" : "Open";
|
||||
}
|
||||
|
||||
public override void Interact(GameObject interactor)
|
||||
public override void Interact()
|
||||
{
|
||||
ToggleDoor();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Unheimlich.Gameplay.Items
|
||||
_levitatingObject = GetComponent<LevitatingObject>();
|
||||
}
|
||||
|
||||
public override void Interact(GameObject interactor)
|
||||
public override void Interact()
|
||||
{
|
||||
if (_blockInteractionDuringAnimation)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Unheimlich.Gameplay.Player
|
||||
|
||||
private HeadBobMode _overrideMode = HeadBobMode.Normal;
|
||||
private bool _hasOverride = false;
|
||||
private Coroutine _resetCoroutine;
|
||||
|
||||
void Start()
|
||||
{
|
||||
@@ -80,6 +81,40 @@ namespace Unheimlich.Gameplay.Player
|
||||
public void ClearOverride()
|
||||
{
|
||||
_hasOverride = false;
|
||||
|
||||
if (_resetCoroutine != null)
|
||||
{
|
||||
StopCoroutine(_resetCoroutine);
|
||||
_resetCoroutine = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Smoothly lerps the head bob position to zero over the specified duration.
|
||||
/// </summary>
|
||||
public void LerpToZero(float duration)
|
||||
{
|
||||
if (_resetCoroutine != null)
|
||||
StopCoroutine(_resetCoroutine);
|
||||
|
||||
_resetCoroutine = StartCoroutine(LerpToZeroCoroutine(duration));
|
||||
}
|
||||
|
||||
private System.Collections.IEnumerator LerpToZeroCoroutine(float duration)
|
||||
{
|
||||
Vector3 startPos = transform.localPosition;
|
||||
float elapsed = 0f;
|
||||
|
||||
while (elapsed < duration)
|
||||
{
|
||||
elapsed += Time.deltaTime;
|
||||
float t = Mathf.Clamp01(elapsed / duration);
|
||||
transform.localPosition = Vector3.Lerp(startPos, Vector3.zero, t);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
transform.localPosition = Vector3.zero;
|
||||
_resetCoroutine = null;
|
||||
}
|
||||
|
||||
private void ApplyBob(float speed, float amplitude)
|
||||
|
||||
+51
-7
@@ -66,6 +66,7 @@ namespace Unheimlich.Gameplay.Player
|
||||
private AudioListenable _currentTargetEmitter;
|
||||
private AudioSource _playerAudioSource;
|
||||
private Coroutine _listeningCoroutine;
|
||||
private Coroutine _vibrationCoroutine;
|
||||
private int _diapasonTweenId = -1;
|
||||
private int _audioListenerFadeTweenId = -1;
|
||||
private int _playerAudioFadeTweenId = -1;
|
||||
@@ -74,7 +75,9 @@ namespace Unheimlich.Gameplay.Player
|
||||
private Vector3 _diapasonHiddenPosition;
|
||||
private bool _canUseDiapason;
|
||||
private bool _isFadingOutConcentration;
|
||||
private Coroutine _vibrationCoroutine;
|
||||
|
||||
private CameraHeadBob _cameraHeadBob;
|
||||
private CameraPanSettings _originalCameraSettings;
|
||||
|
||||
protected override void OnAwake()
|
||||
{
|
||||
@@ -91,6 +94,8 @@ namespace Unheimlich.Gameplay.Player
|
||||
_cameraPanController = gameObject.AddComponent<CameraPanController>();
|
||||
}
|
||||
}
|
||||
|
||||
_cameraHeadBob = GetComponentInChildren<CameraHeadBob>();
|
||||
|
||||
if (_diapasonObject != null)
|
||||
{
|
||||
@@ -236,6 +241,10 @@ namespace Unheimlich.Gameplay.Player
|
||||
|
||||
if (_currentTargetEmitter != null && _cameraPanController != null)
|
||||
{
|
||||
_originalCameraSettings = _cameraPanController.Settings;
|
||||
if(_currentTargetEmitter.CameraPanSettings != null)
|
||||
_cameraPanController.Settings = _currentTargetEmitter.CameraPanSettings;
|
||||
|
||||
_currentTargetEmitter.SetConcentrating(true);
|
||||
|
||||
_cameraPanController.AlignToTarget(_currentTargetEmitter.transform);
|
||||
@@ -263,18 +272,23 @@ namespace Unheimlich.Gameplay.Player
|
||||
|
||||
PlayBreathIn();
|
||||
yield return new WaitForSeconds(_breathInDuration);
|
||||
|
||||
if (_cameraHeadBob != null)
|
||||
{
|
||||
float resetDuration = _concentrationDuration - _breathInDuration;
|
||||
_cameraHeadBob.LerpToZero(resetDuration);
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(_concentrationDuration - _breathInDuration);
|
||||
|
||||
IsConcentrating = false;
|
||||
IsListening = true;
|
||||
|
||||
EnableVignette(true);
|
||||
|
||||
if (_cameraPanController != null)
|
||||
{
|
||||
_cameraPanController.StartPan();
|
||||
}
|
||||
EnableVignette(true);
|
||||
|
||||
ApplyHeadBobSettings(_cameraPanController.Settings);
|
||||
_cameraPanController.StartPan();
|
||||
|
||||
|
||||
Cursor.lockState = CursorLockMode.Confined;
|
||||
Cursor.visible = false;
|
||||
@@ -311,7 +325,15 @@ namespace Unheimlich.Gameplay.Player
|
||||
{
|
||||
_cameraPanController.StopPan();
|
||||
_cameraPanController.ReturnToOriginalPosition();
|
||||
|
||||
if (_originalCameraSettings != null)
|
||||
{
|
||||
_cameraPanController.Settings = _originalCameraSettings;
|
||||
_originalCameraSettings = null;
|
||||
}
|
||||
}
|
||||
|
||||
RestoreHeadBob();
|
||||
|
||||
if (_playerAudioSource != null && _playerAudioSource.isPlaying)
|
||||
{
|
||||
@@ -528,6 +550,28 @@ namespace Unheimlich.Gameplay.Player
|
||||
_vignetteEffect.SetIntensity(_vignetteIntensity);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies head bob settings based on CameraPanSettings configuration.
|
||||
/// </summary>
|
||||
private void ApplyHeadBobSettings(CameraPanSettings settings)
|
||||
{
|
||||
if (_cameraHeadBob == null || settings == null)
|
||||
return;
|
||||
|
||||
_cameraHeadBob.SetMode(settings.HeadBobMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores head bob to normal behavior.
|
||||
/// </summary>
|
||||
private void RestoreHeadBob()
|
||||
{
|
||||
if (_cameraHeadBob == null)
|
||||
return;
|
||||
|
||||
_cameraHeadBob.ClearOverride();
|
||||
}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Unheimlich.Gameplay.Portals
|
||||
/// Handles interaction with the door.
|
||||
/// Toggles both this door and the linked portal's door simultaneously.
|
||||
/// </summary>
|
||||
public override void Interact(GameObject interactor)
|
||||
public override void Interact()
|
||||
{
|
||||
SyncToggle();
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ namespace Unheimlich.Handlers.DetectiveBoard
|
||||
_inspectableItem = GetComponent<InspectableItem>();
|
||||
}
|
||||
|
||||
public override void Interact(GameObject interactor)
|
||||
public override void Interact()
|
||||
{
|
||||
if (_unlockOnlyOnce && _hasUnlocked)
|
||||
{
|
||||
if (_inspectableItem != null)
|
||||
_inspectableItem.Interact(interactor);
|
||||
_inspectableItem.Interact();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Unheimlich.Handlers.DetectiveBoard
|
||||
{
|
||||
Debug.LogError("[ClueUnlockOnInteraction] No clue data assigned!");
|
||||
if (_inspectableItem != null)
|
||||
_inspectableItem.Interact(interactor);
|
||||
_inspectableItem.Interact();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Unheimlich.Handlers.DetectiveBoard
|
||||
|
||||
if (_inspectableItem != null)
|
||||
{
|
||||
_inspectableItem.Interact(interactor);
|
||||
_inspectableItem.Interact();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Unheimlich.Interactions.Dialogues
|
||||
}
|
||||
}
|
||||
|
||||
public override void Interact(GameObject interactor)
|
||||
public override void Interact()
|
||||
{
|
||||
if (DialogueManager.Instance == null)
|
||||
return;
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Unheimlich.Interactions.Core
|
||||
if (interactAction != null && interactAction.WasPressedThisFrame())
|
||||
{
|
||||
if (_currentInteractable != null)
|
||||
_currentInteractable.Interact(transform.parent.gameObject);
|
||||
_currentInteractable.Interact();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,6 @@ namespace Unheimlich.Interactions.Core
|
||||
[Tooltip("Text displayed when the player looks at the object")]
|
||||
public string InteractionText = "Interact";
|
||||
|
||||
public abstract void Interact(GameObject gameObject);
|
||||
public abstract void Interact();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.UI;
|
||||
using Unheimlich.Gameplay.DetectiveBoard;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Unheimlich.UI.DetectiveBoard
|
||||
{
|
||||
@@ -20,7 +22,8 @@ namespace Unheimlich.UI.DetectiveBoard
|
||||
[SerializeField] private DetectiveBoardController _boardController;
|
||||
|
||||
[Header("Settings")]
|
||||
[SerializeField] private float _maxInteractionDistance = 5f;
|
||||
[SerializeField] private float _minInteractionDistance = 0.1f;
|
||||
[SerializeField] private float _maxInteractionDistance = 10f;
|
||||
|
||||
private DetectiveBoardCanvas _canvasManager;
|
||||
private PostItNode _hoveredNode;
|
||||
@@ -253,26 +256,20 @@ namespace Unheimlich.UI.DetectiveBoard
|
||||
|
||||
private PostItNode RaycastForNode()
|
||||
{
|
||||
if (_camera == null)
|
||||
if (_camera == null || Mouse.current == null)
|
||||
return null;
|
||||
|
||||
Vector2 mousePos = Mouse.current.position.ReadValue();
|
||||
Ray ray = _camera.ScreenPointToRay(new Vector3(mousePos.x, mousePos.y, 0));
|
||||
|
||||
if (Physics.Raycast(ray, out RaycastHit hit, _maxInteractionDistance, _boardLayer))
|
||||
GraphicRaycaster raycaster = _boardCanvas?.GetComponent<GraphicRaycaster>();
|
||||
if (raycaster != null && EventSystem.current != null)
|
||||
{
|
||||
return hit.collider.GetComponentInParent<PostItNode>();
|
||||
}
|
||||
|
||||
GraphicRaycaster raycaster = _boardCanvas.GetComponent<GraphicRaycaster>();
|
||||
if (raycaster != null)
|
||||
{
|
||||
var pointerEventData = new UnityEngine.EventSystems.PointerEventData(UnityEngine.EventSystems.EventSystem.current)
|
||||
var pointerEventData = new PointerEventData(EventSystem.current)
|
||||
{
|
||||
position = mousePos
|
||||
};
|
||||
|
||||
var results = new System.Collections.Generic.List<UnityEngine.EventSystems.RaycastResult>();
|
||||
var results = new List<RaycastResult>();
|
||||
raycaster.Raycast(pointerEventData, results);
|
||||
|
||||
foreach (var result in results)
|
||||
@@ -283,6 +280,17 @@ namespace Unheimlich.UI.DetectiveBoard
|
||||
}
|
||||
}
|
||||
|
||||
Ray ray = _camera.ScreenPointToRay(new Vector3(mousePos.x, mousePos.y, 0));
|
||||
|
||||
if (Physics.Raycast(ray, out RaycastHit hit, _maxInteractionDistance, _boardLayer))
|
||||
{
|
||||
float distance = hit.distance;
|
||||
if (distance >= _minInteractionDistance)
|
||||
{
|
||||
return hit.collider.GetComponentInParent<PostItNode>();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user