wip : Liminal spaces + Tidy up
This commit is contained in:
+30
-29
@@ -3,11 +3,11 @@ using UnityEngine;
|
||||
namespace Unheimlich.World.HouseOfLeaves
|
||||
{
|
||||
/// <summary>
|
||||
/// Animates the sand terrain rising from below the corridor floor
|
||||
/// based on the player's progression through the corridor.
|
||||
/// Animates the sand terrain shader progression based on the player's
|
||||
/// advancement through the corridor.
|
||||
///
|
||||
/// The terrain starts buried underground and slowly emerges as the
|
||||
/// player advances, simulating sand flooding the corridor from below.
|
||||
/// Drives the _Progression float on the sand material from 0 to 1,
|
||||
/// simulating sand flooding the corridor as the player advances.
|
||||
/// </summary>
|
||||
public class SandTerrainController : MonoBehaviour
|
||||
{
|
||||
@@ -19,23 +19,22 @@ namespace Unheimlich.World.HouseOfLeaves
|
||||
[Tooltip("The HouseOfLeavesController driving the progression value.")]
|
||||
[SerializeField] private HouseOfLeavesController _controller;
|
||||
|
||||
[Tooltip("The sand terrain Transform to animate.")]
|
||||
[Tooltip("The sand terrain Transform holding the sand material.")]
|
||||
[SerializeField] private Transform _sandTerrain;
|
||||
|
||||
[Header("Rise Settings")]
|
||||
[Tooltip("Y position of the terrain at the start (buried underground).")]
|
||||
[SerializeField] private float _startY = -4f;
|
||||
|
||||
[Tooltip("Y position of the terrain at full progression (emerged).")]
|
||||
[SerializeField] private float _endY = 0.5f;
|
||||
|
||||
[Tooltip("Lerp speed applied to the vertical movement each frame.")]
|
||||
[SerializeField] private float _lerpSpeed = 2f;
|
||||
|
||||
[Tooltip("Animation curve mapping progression [0,1] to rise amount [0,1]. " +
|
||||
"Use this to delay the rise until mid-corridor for example.")]
|
||||
[Header("Progression Settings")]
|
||||
[Tooltip("Animation curve mapping progression [0,1] to shader value [0,1]. " +
|
||||
"Use this to delay or ease the sand appearance.")]
|
||||
[SerializeField] private AnimationCurve _riseCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Private Fields
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
private Renderer _renderer;
|
||||
|
||||
private static readonly int ProgressionID = Shader.PropertyToID("_Progression");
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Unity Messages
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
@@ -54,22 +53,24 @@ namespace Unheimlich.World.HouseOfLeaves
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize position immediately without lerp.
|
||||
Vector3 startPos = _sandTerrain.position;
|
||||
startPos.y = _startY;
|
||||
_sandTerrain.position = startPos;
|
||||
_renderer = _sandTerrain.GetComponent<Renderer>();
|
||||
|
||||
if (_renderer == null)
|
||||
{
|
||||
Debug.LogError("[SandTerrainController] No Renderer found on sand terrain.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize shader progression to zero.
|
||||
_renderer.material.SetFloat(ProgressionID, 0f);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_controller == null || _sandTerrain == null) return;
|
||||
if (_controller == null || _renderer == null) return;
|
||||
|
||||
float t = _riseCurve.Evaluate(_controller.Progression);
|
||||
float targetY = Mathf.Lerp(_startY, _endY, t);
|
||||
|
||||
Vector3 pos = _sandTerrain.position;
|
||||
pos.y = Mathf.Lerp(pos.y, targetY, Time.deltaTime * _lerpSpeed);
|
||||
_sandTerrain.position = pos;
|
||||
float t = _riseCurve.Evaluate(_controller.Progression);
|
||||
_renderer.material.SetFloat(ProgressionID, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,7 +175,7 @@ public class ScarecrowFire : MonoBehaviour
|
||||
|
||||
el.VFX.SetActive(true);
|
||||
|
||||
Vector3 startScale = el.VFX.transform.localScale;
|
||||
Vector3 startScale = Vector3.zero;
|
||||
Vector3 targetScale = el.OriginalScale;
|
||||
float elapsed = 0f;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user