|
@@ -3,11 +3,11 @@ using UnityEngine;
|
|
|
public class EnergyOrb : MonoBehaviour
|
|
public class EnergyOrb : MonoBehaviour
|
|
|
{
|
|
{
|
|
|
[Header("Orb Save Data")]
|
|
[Header("Orb Save Data")]
|
|
|
- public string ID; // unique ID for each of this orb
|
|
|
|
|
|
|
+ public string ID;
|
|
|
public bool Collected = false;
|
|
public bool Collected = false;
|
|
|
|
|
|
|
|
[Header("Sound")]
|
|
[Header("Sound")]
|
|
|
- public AudioClip pickupSound; // assign your .wav in the inspector
|
|
|
|
|
|
|
+ public AudioClip pickupSound;
|
|
|
public float volume = 1f;
|
|
public float volume = 1f;
|
|
|
|
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
private void OnTriggerEnter(Collider other)
|
|
@@ -16,17 +16,14 @@ public class EnergyOrb : MonoBehaviour
|
|
|
{
|
|
{
|
|
|
Collected = true;
|
|
Collected = true;
|
|
|
|
|
|
|
|
- // Play the pickup sound without needing the orb to stay active
|
|
|
|
|
if (pickupSound != null)
|
|
if (pickupSound != null)
|
|
|
{
|
|
{
|
|
|
- // Play from the main camera (or any object that won't be disabled)
|
|
|
|
|
|
|
+ // Play from the main camera
|
|
|
AudioSource.PlayClipAtPoint(pickupSound, Camera.main.transform.position, volume);
|
|
AudioSource.PlayClipAtPoint(pickupSound, Camera.main.transform.position, volume);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Send the GameManager that it's been collected
|
|
|
|
|
GameManager.Instance.CollectOrb();
|
|
GameManager.Instance.CollectOrb();
|
|
|
|
|
|
|
|
- // Deactivate the orb
|
|
|
|
|
gameObject.SetActive(false);
|
|
gameObject.SetActive(false);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|