Skip to content

Commit

Permalink
fix: disable up when game objects dependencies are not set
Browse files Browse the repository at this point in the history
  • Loading branch information
Aniol0012 committed Dec 11, 2024
1 parent b56fde3 commit 6c2dd2d
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions Assets/Scripts/Mechanics/Movement/Up.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlayerController>();
_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;
}
}

Expand All @@ -42,7 +37,6 @@ private void LookUp() {
}

_playerController.SetMovementState(PlayerMovementState.Up);

CameraManager.Instance.SetOffset(new Vector2(0, lookUpOffset));
}
}
Expand Down

0 comments on commit 6c2dd2d

Please sign in to comment.