wip : Liminal spaces + Tidy up

This commit is contained in:
2026-05-22 11:59:09 +01:00
parent a47cebc99b
commit cb0bcb5df3
76 changed files with 7438 additions and 15195 deletions
@@ -35,12 +35,6 @@ namespace OctoCore.Components
public PlayerModes Mode = PlayerModes.FirstPerson;
public Orientations Orientation = Orientations.Camera;
[Tooltip("Allow position movement.")]
public bool AllowMove = true;
[Tooltip("Allow looking around.")]
public bool AllowLook = true;
[Tooltip("Walk speed (km/h).")]
public float WalkSpeed = 10;
@@ -407,10 +401,8 @@ namespace OctoCore.Components
{
Vector2 delta = (State.IsPaused || !State.IsFocussed) ? Vector2.zero : _lookInput;
if (_settings.AllowLook)
{
float mouseX = delta.x * _firstPerson.SensitivityX;
float mouseY = delta.y * _firstPerson.SensitivityY * -1;
float mouseX = delta.x * _firstPerson.SensitivityX;
float mouseY = delta.y * _firstPerson.SensitivityY * -1;
State.Yaw += mouseX;
State.Pitch = Mathf.Clamp(State.Pitch + mouseY, _firstPerson.MinPitch, _firstPerson.MaxPitch);
@@ -39,7 +39,7 @@ namespace OctoCore.Components
[Tooltip("Type of animation loop")]
public AnimationType Type = AnimationType.PingPong;
[Tooltip("TCenter of animation")]
[Tooltip("Center of animation")]
public AnimationBalance Balance = AnimationBalance.Centered;
[Tooltip("Custom animation curve")]
@@ -48,10 +48,13 @@ namespace OctoCore.Components
[Tooltip("Play on Awake")]
public bool PlayOnAwake = true;
[Tooltip("Delay before playing (seconds)")]
public float Delay = 0f;
[Tooltip("Random Time Offset")]
public bool RandomOffset = true;
[Tooltip("Animation speed multiplier")]
[Tooltip("Animation duration (seconds)")]
public float Duration = 4;
[Tooltip("Cycle offset to desynchronize multiple animations")]
@@ -95,16 +98,24 @@ namespace OctoCore.Components
void OnEnable()
{
_timeOffset = Time.timeSinceLevelLoad;
_started = _settings.PlayOnAwake;
_started = false;
if (_settings.PlayOnAwake)
{
if (_settings.Delay > 0f)
StartCoroutine(DelayedStart());
else
_started = true;
}
}
void Start()
{
_state.InitialPosition = transform.localPosition;
_state.InitialRotation = transform.localRotation;
_state.InitialScale = transform.localScale;
_state.CurrentTime = _settings.CycleOffset;
_state.IsFinished = false;
_state.InitialScale = transform.localScale;
_state.CurrentTime = _settings.CycleOffset;
_state.IsFinished = false;
_timeOffset = Time.timeSinceLevelLoad;
}
@@ -114,15 +125,16 @@ namespace OctoCore.Components
if (_state.IsFinished || !_started)
return;
_state.CurrentTime = Time.timeSinceLevelLoad + _settings.CycleOffset * _settings.Duration - _timeOffset + (_settings.RandomOffset ? transform.GetSiblingIndex() * 6.7f : 0);
_state.CurrentTime = Time.timeSinceLevelLoad + _settings.CycleOffset * _settings.Duration - _timeOffset
+ (_settings.RandomOffset ? transform.GetSiblingIndex() * 6.7f : 0);
float normalizedTime = GetNormalizedTime(_state.CurrentTime);
float easedTime = ApplyEasing(normalizedTime);
float balanceTime = ApplyBalance(easedTime);
float easedTime = ApplyEasing(normalizedTime);
float balancedTime = ApplyBalance(easedTime);
ApplyTranslation(balanceTime);
ApplyRotation(balanceTime);
ApplyScale(balanceTime);
ApplyTranslation(balancedTime);
ApplyRotation(balancedTime);
ApplyScale(balancedTime);
}
/// <summary>
@@ -142,10 +154,10 @@ namespace OctoCore.Components
public void ResetAnimation()
{
_state.CurrentTime = _settings.CycleOffset;
_state.IsFinished = false;
_state.IsFinished = false;
transform.localPosition = _state.InitialPosition;
transform.localRotation = _state.InitialRotation;
transform.localScale = _state.InitialScale;
transform.localScale = _state.InitialScale;
}
/// <summary>
@@ -156,6 +168,16 @@ namespace OctoCore.Components
enabled = !paused;
}
/// <summary>
/// Waits for the configured delay then starts the animation.
/// </summary>
private System.Collections.IEnumerator DelayedStart()
{
yield return new WaitForSeconds(_settings.Delay);
_timeOffset = Time.timeSinceLevelLoad;
_started = true;
}
/// <summary>
/// Gets normalized time [0,1] based on animation type.
/// </summary>
@@ -188,6 +210,9 @@ namespace OctoCore.Components
}
}
/// <summary>
/// Applies balance offset to eased time.
/// </summary>
private float ApplyBalance(float time)
{
switch (_settings.Balance)
@@ -211,7 +236,7 @@ namespace OctoCore.Components
switch (_settings.Type)
{
default:
return _settings.Curve.Evaluate(time); ;
return _settings.Curve.Evaluate(time);
case AnimationType.Constant:
return time;
@@ -241,8 +266,9 @@ namespace OctoCore.Components
if (_settings.Rotation == Vector3.zero)
return;
Vector3 rotation = _settings.Rotation * time;
Vector3 rotation = _settings.Rotation * time;
Quaternion rotationOffset = Quaternion.Euler(rotation);
if (_settings.Space == AnimationSpace.Local)
rotationOffset = _state.InitialRotation * rotationOffset;
else