TO SQUASH: Fixed issue with yummy missed sound playing multiple times.

This commit is contained in:
2026-08-10 22:58:50 -04:00
parent 1b10a2f144
commit 14aa42696e
14 changed files with 336 additions and 50 deletions
+9 -3
View File
@@ -1,4 +1,5 @@
using UnityEngine;
using System.Collections;
public abstract class YummyBase : MonoBehaviour
{
@@ -20,6 +21,8 @@ public abstract class YummyBase : MonoBehaviour
private float missedTimer = 0f;
private bool isMissed = false;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
@@ -32,7 +35,7 @@ public abstract class YummyBase : MonoBehaviour
// Update is called once per frame
void FixedUpdate()
{
if (isObtained)
if (isObtained || isMissed)
{
return;
}
@@ -41,10 +44,12 @@ public abstract class YummyBase : MonoBehaviour
missedTimer += Time.fixedDeltaTime;
if (missedTimer >= 5f)
if (missedTimer >= 5f && !isMissed)
{
isMissed = true;
audioSource.PlayOneShot(missedSound);
animator.SetTrigger("missed");
StartCoroutine(DestroyYummy());
}
}
@@ -85,8 +90,9 @@ public abstract class YummyBase : MonoBehaviour
}
}
public void DestroyYummy()
public IEnumerator DestroyYummy()
{
yield return new WaitForSeconds(1.5f);
Destroy(gameObject);
}