Orb.cs 762 B

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