diff --git a/Game/Assets/Scripts/BroomSweeping.cs b/Game/Assets/Scripts/BroomSweeping.cs index 9284103..d012d73 100644 --- a/Game/Assets/Scripts/BroomSweeping.cs +++ b/Game/Assets/Scripts/BroomSweeping.cs @@ -16,15 +16,19 @@ public class BroomSweeping : MonoBehaviour private void OnTriggerEnter(Collider other) { - if (!other.CompareTag("Dirt")) return; - - dirtSweeped++; - Destroy(other.gameObject); - - // Play sound only if no other sound is currently playing - if (!audioSource.isPlaying) + if (!other.CompareTag("Dirt")) { - audioSource.PlayOneShot(sweepingSound); + // Add to dirt swept count + dirtSweeped++; + + // Destroy it to prevent extra counting + Destroy(other.gameObject); + + // Play sound only if no other sound is currently playing + if (!audioSource.isPlaying) + { + audioSource.PlayOneShot(sweepingSound); + } } } } \ No newline at end of file diff --git a/Game/Assets/Scripts/Sweeping.cs b/Game/Assets/Scripts/SweepingTask.cs similarity index 98% rename from Game/Assets/Scripts/Sweeping.cs rename to Game/Assets/Scripts/SweepingTask.cs index f939b4f..cb3473e 100644 --- a/Game/Assets/Scripts/Sweeping.cs +++ b/Game/Assets/Scripts/SweepingTask.cs @@ -9,7 +9,7 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; -public class Sweeping : MonoBehaviour +public class SweepingTask : MonoBehaviour { public Transform broomParent; // Assign the parent object of the broom public float sweepSpeed = 2f; // Speed of automatic sweeping diff --git a/Game/Assets/Scripts/Sweeping.cs.meta b/Game/Assets/Scripts/SweepingTask.cs.meta similarity index 100% rename from Game/Assets/Scripts/Sweeping.cs.meta rename to Game/Assets/Scripts/SweepingTask.cs.meta