game: misc
This commit is contained in:
parent
d228d1cd34
commit
388b39b511
3 changed files with 13 additions and 9 deletions
|
@ -16,9 +16,12 @@ public class BroomSweeping : MonoBehaviour
|
||||||
|
|
||||||
private void OnTriggerEnter(Collider other)
|
private void OnTriggerEnter(Collider other)
|
||||||
{
|
{
|
||||||
if (!other.CompareTag("Dirt")) return;
|
if (!other.CompareTag("Dirt"))
|
||||||
|
{
|
||||||
|
// Add to dirt swept count
|
||||||
dirtSweeped++;
|
dirtSweeped++;
|
||||||
|
|
||||||
|
// Destroy it to prevent extra counting
|
||||||
Destroy(other.gameObject);
|
Destroy(other.gameObject);
|
||||||
|
|
||||||
// Play sound only if no other sound is currently playing
|
// Play sound only if no other sound is currently playing
|
||||||
|
@ -27,4 +30,5 @@ public class BroomSweeping : MonoBehaviour
|
||||||
audioSource.PlayOneShot(sweepingSound);
|
audioSource.PlayOneShot(sweepingSound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@ using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class Sweeping : MonoBehaviour
|
public class SweepingTask : MonoBehaviour
|
||||||
{
|
{
|
||||||
public Transform broomParent; // Assign the parent object of the broom
|
public Transform broomParent; // Assign the parent object of the broom
|
||||||
public float sweepSpeed = 2f; // Speed of automatic sweeping
|
public float sweepSpeed = 2f; // Speed of automatic sweeping
|
Loading…
Add table
Reference in a new issue