Smooth 3C & simplify hallucination trigger

This commit is contained in:
Ferlat Thibaud
2026-03-22 18:03:21 +01:00
parent 0d968f75ab
commit 1589a7a543
24 changed files with 1318 additions and 621 deletions
@@ -36,34 +36,19 @@ namespace Unheimlich.Features.Player
public InputManager Inputs => InputManager.Instance;
public bool IsMoving
{
get
{
// Read directly from action instead of cached value
var moveAction = InputManager.GetMoveAction();
if (moveAction == null) return false;
return moveAction.ReadValue<UnityEngine.Vector2>().magnitude > 0.1f;
}
}
public bool IsRunning
{
get
{
if (Movement == null || OctoCore.OctoCore.Instance == null) return false;
var actions = OctoCore.OctoCore.Instance.Inputs?.Actions;
if (actions != null)
{
foreach (var actionInfo in actions)
{
if (actionInfo.Name == "Sprint" && actionInfo.Reference != null)
return actionInfo.Reference.action.IsPressed();
}
}
return false;
}
}
// Cached sprint InputAction — resolved once in OnAwake to avoid per-frame foreach.
private UnityEngine.InputSystem.InputAction _sprintAction;
/// <summary>
/// True when the character is physically moving (based on CharacterController velocity,
/// not raw input — correctly synced with OctoPlayer's inertia).
/// </summary>
public bool IsMoving => CharController != null && CharController.velocity.magnitude > 0.1f;
/// <summary>
/// True while the sprint input is held and the player is moving.
/// </summary>
public bool IsRunning => _sprintAction != null && _sprintAction.IsPressed() && IsMoving;
protected override void OnAwake()
{
@@ -76,15 +61,34 @@ namespace Unheimlich.Features.Player
DiapasonEquipment = GetComponent<DiapasonEquipmentManager>();
InspectionHandler = GetComponent<PlayerInspectionHandler>();
DetectiveBoardController = GetComponent<DetectiveBoardController>();
PlayerCamera = GetComponentInChildren<Camera>();
ArmsSystem = GetComponentInChildren<OctoIkArmsImproved>();
if (PlayerCamera != null)
{
CameraTransform = PlayerCamera.transform;
CameraPivot = CameraTransform.parent;
}
CacheSprintAction();
}
/// <summary>
/// Resolves the Sprint InputAction once from OctoCore to avoid per-frame foreach iteration.
/// </summary>
private void CacheSprintAction()
{
if (OctoCore.OctoCore.Instance?.Inputs?.Actions == null) return;
foreach (var actionInfo in OctoCore.OctoCore.Instance.Inputs.Actions)
{
if (actionInfo.Name == "Sprint" && actionInfo.Reference != null)
{
_sprintAction = actionInfo.Reference.action;
break;
}
}
}
// Teleport