Skip to content
Merged

Um #22

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions ScrollZoom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static class HudManager_Update_Patch
private const float MaxZoom = 15f;
private const float ZoomStep = 1.25f;

private const float ZoomSmoothSpeed = 12f;
private const float ZoomSmoothSpeed = 30f; // higher = snappier interpolation

private static float _targetZoom = -1f;
private static float _defaultZoom = -1f;
Expand Down Expand Up @@ -52,7 +52,7 @@ static void Postfix()
if (Minigame.Instance != null || HudManager.Instance.GameMenu.IsOpen)
return;

// chat scroll fix
// prevent zoom when chat is open
if (HudManager.Instance?.Chat != null && HudManager.Instance.Chat.IsOpenOrOpening)
return;

Expand Down Expand Up @@ -94,13 +94,10 @@ private static void SmoothZoomStep()

float current = Camera.main.orthographicSize;

float t = Time.deltaTime * ZoomSmoothSpeed;
float eased = t * t;
float newZoom = Mathf.Lerp(current, _targetZoom, Time.deltaTime * ZoomSmoothSpeed);

float newZoom = Mathf.Lerp(current, _targetZoom, eased);

// snap to target zoom when very close (fix shadow bug)
if (Mathf.Abs(newZoom - _targetZoom) < 0.01f)
// snap exactly to target when close
if (Mathf.Abs(newZoom - _targetZoom) < 0.02f)
newZoom = _targetZoom;

ApplyZoom(newZoom);
Expand Down