game: misc

This commit is contained in:
rezazfn 2025-02-08 22:49:54 +08:00
parent d228d1cd34
commit 388b39b511
3 changed files with 13 additions and 9 deletions

View file

@ -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);
}
}
}
}

View file

@ -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