From 5ff756b5e54ddaf899545d4c23c5d924bd7415c6 Mon Sep 17 00:00:00 2001 From: Adrian Paschkowski <git@wasdennnoch.me> Date: Sat, 10 Apr 2021 21:23:44 +0200 Subject: [PATCH] CamController: Disable collider during animation --- Assets/Scripts/BaseCameraController.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/BaseCameraController.cs b/Assets/Scripts/BaseCameraController.cs index 4d02e6b..ca53edb 100644 --- a/Assets/Scripts/BaseCameraController.cs +++ b/Assets/Scripts/BaseCameraController.cs @@ -78,6 +78,9 @@ public class BaseCameraController : MonoBehaviour AnimateToPosition(player.transform.position + new Vector3(0f, 0.75f), 1.5f, 0.1f); } + // Disable collider while there is an ongoing animation + collider.enabled = !HasOverriddenOnterpolators(); + mouseMovementEdges.DrawDebug(!IsUserControlEnabled() ? Color.yellow : waitForMouseOutsideEdges ? Color.red : Color.green); if (IsUserControlEnabled()) { @@ -117,6 +120,7 @@ public class BaseCameraController : MonoBehaviour zoomInterpolator.targetValue += inputZoomDelta; } } + // Always interpolate zoom as that might be animted without user input enabled if (zoomInterpolator.running) { @@ -147,7 +151,12 @@ public class BaseCameraController : MonoBehaviour bool IsUserControlEnabled() { - return allowUserControl && !zoomInterpolator.hasInterpolatorsQueued && !xPositionInterpolator.hasInterpolatorsQueued && !yPositionInterpolator.hasInterpolatorsQueued; + return allowUserControl && !HasOverriddenOnterpolators(); + } + + bool HasOverriddenOnterpolators() + { + return zoomInterpolator.hasInterpolatorsQueued || xPositionInterpolator.hasInterpolatorsQueued || yPositionInterpolator.hasInterpolatorsQueued; } // Resize the attached collider to fit the visible camera bounds -- GitLab