Orb.cs 848 B

123456789101112131415161718192021222324252627282930313233
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. public class Orb : MonoBehaviour
  4. {
  5. private GameObject miniMapCamera;
  6. [SerializeField] AudioSource audioSource;
  7. private void Awake()
  8. {
  9. Canvas canvas = GetComponentInChildren<Canvas>();
  10. if(miniMapCamera == null)
  11. {
  12. miniMapCamera = GameObject.Find("MiniMapCamera");
  13. }
  14. if(canvas && canvas.renderMode == RenderMode.WorldSpace)
  15. {
  16. canvas.worldCamera = miniMapCamera.GetComponent<Camera>();
  17. }
  18. }
  19. private void OnTriggerEnter(Collider other)
  20. {
  21. if(other.gameObject.name == "Player")
  22. {
  23. //Debug.Log("Player collected an orb");
  24. GameManager.gameManagerInstance.IncreaseOrbCounter();
  25. audioSource.Play();
  26. Destroy(gameObject, 0.2f);
  27. }
  28. }
  29. }