fix : triggering dizziness
This commit is contained in:
@@ -36,8 +36,11 @@ namespace Unheimlich.World.CameraSystem
|
||||
[Tooltip("Enable or disable the whole rig (with fade). Can also be toggled at runtime via SetActive().")]
|
||||
[SerializeField] private bool _isActive = true;
|
||||
|
||||
[Tooltip("Master scale applied to ALL effects (noise amplitude, jolt amplitude, inertia strength, spin strength). 0 = off, 1 = nominal.")]
|
||||
[SerializeField] [Range(0f, 3f)] private float _masterIntensity = 1f;
|
||||
[Tooltip("Master scale applied to ALL effects. This is the target value restored on Enable().")]
|
||||
[SerializeField] [Range(0f, 3f)] private float _masterIntensityInspector = 1f;
|
||||
|
||||
// Runtime value — starts at 0 if disabled, lerps to _masterIntensityInspector on Enable().
|
||||
private float _masterIntensity;
|
||||
|
||||
// ── Inspector — Stress ────────────────────────────────────────────────────
|
||||
|
||||
@@ -140,7 +143,7 @@ namespace Unheimlich.World.CameraSystem
|
||||
// ── Runtime state ─────────────────────────────────────────────────────────
|
||||
|
||||
private float _weight;
|
||||
private float _initialMasterIntensity; // value set in inspector, restored on Enable()
|
||||
private bool _started;
|
||||
private float _noiseTimer;
|
||||
private float _spinTimer;
|
||||
private Vector3 _noiseOffset;
|
||||
@@ -165,17 +168,16 @@ namespace Unheimlich.World.CameraSystem
|
||||
Random.Range(0f, 100f)
|
||||
);
|
||||
|
||||
// Spin uses its own offset to decouple from the main noise.
|
||||
_spinTimer = Random.Range(0f, 100f);
|
||||
|
||||
// _masterIntensity is a pure runtime field (not serialized) so this zero
|
||||
// will never be overwritten by Unity's deserialization.
|
||||
_masterIntensity = _isActive ? _masterIntensityInspector : 0f;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Store the inspector value so Enable() can restore it even if the rig
|
||||
// started disabled (and _masterIntensity was faded to 0).
|
||||
_initialMasterIntensity = _masterIntensity;
|
||||
|
||||
// Sync inspector toggle on first frame.
|
||||
_started = true;
|
||||
IsActive = _isActive;
|
||||
_weight = _isActive ? 1f : 0f;
|
||||
|
||||
@@ -190,8 +192,7 @@ namespace Unheimlich.World.CameraSystem
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
// Allow toggling _isActive from the inspector during Play mode.
|
||||
if (!Application.isPlaying) return;
|
||||
if (!Application.isPlaying || !_started) return;
|
||||
SetActive(_isActive);
|
||||
}
|
||||
|
||||
@@ -290,7 +291,7 @@ namespace Unheimlich.World.CameraSystem
|
||||
// ── Public API ────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>UnityEvent-friendly wrapper — enables with the inspector master intensity.</summary>
|
||||
public void Enable() => Enable(_initialMasterIntensity, _stressLevel);
|
||||
public void Enable() => Enable(_masterIntensityInspector, _stressLevel);
|
||||
|
||||
/// <summary>UnityEvent-friendly wrapper — disables with a fade to 0.</summary>
|
||||
public void Disable() => Disable(0f);
|
||||
|
||||
Reference in New Issue
Block a user