From 6a2646bc02c61811d91e3fbfd10fbbd710eaf722 Mon Sep 17 00:00:00 2001 From: Adrian Paschkowski <git@wasdennnoch.me> Date: Sun, 11 Apr 2021 18:36:41 +0200 Subject: [PATCH] Adjust interpolator cutoff threshold, fix edge debug draw --- Assets/Scripts/BaseCameraController.cs | 6 +++++- Assets/Scripts/utils/Interpolator.cs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/BaseCameraController.cs b/Assets/Scripts/BaseCameraController.cs index 9138d25..195f4bd 100644 --- a/Assets/Scripts/BaseCameraController.cs +++ b/Assets/Scripts/BaseCameraController.cs @@ -81,7 +81,6 @@ public class BaseCameraController : MonoBehaviour // Disable collider while there is an ongoing animation collider.enabled = !HasOverriddenOnterpolators(); - mouseMovementEdges.DrawDebug(!IsUserControlEnabled() ? Color.yellow : waitForMouseOutsideEdges ? Color.red : Color.green); if (IsUserControlEnabled()) { // Keyboard input @@ -101,6 +100,7 @@ public class BaseCameraController : MonoBehaviour // Mouse input var mouseViewportPos = camera.ScreenToViewportPoint(Input.mousePosition); var mouseInputVector = mouseMovementEdges.GetOutOfBoundsDirection(mouseViewportPos); + mouseMovementEdges.DrawDebug(waitForMouseOutsideEdges ? Color.red : Color.green); if (waitForMouseOutsideEdges && mouseInputVector.magnitude == 0) { // If mouse input was disabled and mouse left edge zone, re-enable mouse input @@ -120,6 +120,10 @@ public class BaseCameraController : MonoBehaviour zoomInterpolator.targetValue += inputZoomDelta; } } + else + { + mouseMovementEdges.DrawDebug(Color.yellow); + } // Always interpolate zoom as that might be animted without user input enabled if (zoomInterpolator.running) diff --git a/Assets/Scripts/utils/Interpolator.cs b/Assets/Scripts/utils/Interpolator.cs index bfbb243..dd2238a 100644 --- a/Assets/Scripts/utils/Interpolator.cs +++ b/Assets/Scripts/utils/Interpolator.cs @@ -53,7 +53,7 @@ public class Interpolator if (running) { currentValue = Mathf.SmoothDamp(currentValue, _targetValue, ref velocity, duration); - if (Mathf.Abs(velocity) < 0.01f) + if (Mathf.Abs(velocity) < 0.0025f) { running = false; currentValue = targetValue; -- GitLab