From 6c2dd2dbf062cd8a437d1b4b41cecd4839746112 Mon Sep 17 00:00:00 2001 From: Aniol0012 Date: Wed, 11 Dec 2024 22:21:36 +0100 Subject: [PATCH] fix: disable up when game objects dependencies are not set --- Assets/Scripts/Mechanics/Movement/Up.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Assets/Scripts/Mechanics/Movement/Up.cs b/Assets/Scripts/Mechanics/Movement/Up.cs index 7be8c01..48ff699 100644 --- a/Assets/Scripts/Mechanics/Movement/Up.cs +++ b/Assets/Scripts/Mechanics/Movement/Up.cs @@ -10,18 +10,13 @@ public class Up : MonoBehaviour { [SerializeField] private float lookUpOffset = 1.3f; private PlayerController _playerController; - private bool _isCameraManagerValid; private void Awake() { _playerController = GetComponent(); - _isCameraManagerValid = CameraManager.Instance != null; - if (_playerController == null) { - Debug.LogWarning("PlayerController is not set."); - } - - if (!_isCameraManagerValid) { - Debug.LogWarning("CameraManager is not set."); + if (_playerController == null || CameraManager.Instance == null) { + Debug.LogError("Up script requires a PlayerController and CameraManager component"); + enabled = false; } } @@ -42,7 +37,6 @@ private void LookUp() { } _playerController.SetMovementState(PlayerMovementState.Up); - CameraManager.Instance.SetOffset(new Vector2(0, lookUpOffset)); } }