Add focused word scale-down and smooth camera shake + unfocus words scribble

This commit is contained in:
2026-01-27 20:13:18 +01:00
parent d1b7104676
commit b64a57d810
16 changed files with 764 additions and 32 deletions
@@ -38,6 +38,9 @@ namespace Unheimlich.Gameplay.Player
[SerializeField] private float _shakeFrequency = 40f;
private float _shakeInterval;
private float _shakeTimer = 0f;
private Vector3 _shakeTarget = Vector3.zero;
private Vector3 _shakeOriginalPos = Vector3.zero;
private float _shakeSmoothness = 0f;
private float _horizontalRotation;
private float _verticalRotation;
@@ -140,20 +143,31 @@ namespace Unheimlich.Gameplay.Player
/// Creates a random camera shake effect for feedback (e.g., impacts, events).
/// Uses a timer-based interval to control shake frequency.
/// Amplitude controls both the intensity and duration of the shake.
/// Smoothness controls how quickly the camera interpolates to the shake position (0 = instant, higher = smoother).
/// </summary>
public void Shake(float amplitude)
public void Shake(float amplitude, float smoothness = 0f)
{
_shakeSmoothness = smoothness;
_shakeTimer -= Time.deltaTime;
if (_shakeTimer <= 0f)
{
_shakeTimer = _shakeInterval * amplitude;
_shakeTimer = _shakeInterval * amplitude;
_shakeOriginalPos = _playerCameraPivot.position;
float x = Random.Range(-1f, 1f) * amplitude;
float y = Random.Range(-1f, 1f) * amplitude;
Vector3 originalPos = _playerCameraPivot.position;
_playerCameraPivot.position = originalPos + new Vector3(x, y, 0f);
_shakeTarget = _shakeOriginalPos + new Vector3(x, y, 0f);
}
if (_shakeSmoothness > 0f)
{
_playerCameraPivot.position = Vector3.Lerp(_playerCameraPivot.position, _shakeTarget, Time.deltaTime * _shakeSmoothness);
}
else
{
_playerCameraPivot.position = _shakeTarget;
}
}