diff --git a/Game/Assets/Scripts/TrashBinTracker.cs b/Game/Assets/Scripts/TrashBinTracker.cs index 713d954..12373e9 100644 --- a/Game/Assets/Scripts/TrashBinTracker.cs +++ b/Game/Assets/Scripts/TrashBinTracker.cs @@ -8,30 +8,29 @@ using UnityEngine; public class TrashBinTracker : MonoBehaviour { - private BedroomTask bedroomTask; + private BedroomTask _bedroomTask; private void Start() { // Find the BedroomTask script in the scene - bedroomTask = FindObjectOfType(); + _bedroomTask = FindObjectOfType(); - if (bedroomTask == null) Debug.LogWarning("BedroomTask script not found in the scene!"); + if (_bedroomTask == null) Debug.LogWarning("BedroomTask script not found in the scene!"); } private void OnTriggerEnter(Collider other) { - if (other.CompareTag("TrashBin")) + if (!other.CompareTag("TrashBin")) return; + + if (_bedroomTask != null) { - if (bedroomTask != null) - { - bedroomTask.CollectTrash(); - Debug.Log("🗑️ Trash thrown in the bin! Count: " + bedroomTask.trashCollected); - Destroy(gameObject); - } - else - { - Debug.LogError("BedroomTask reference is missing!"); - } + _bedroomTask.CollectTrash(); + Debug.Log("🗑️ Trash thrown in the bin! Count: " + _bedroomTask.trashCollected); + Destroy(gameObject); + } + else + { + Debug.LogError("BedroomTask reference is missing!"); } } } \ No newline at end of file