SoulCollector.cs 664 B

123456789101112131415161718192021222324252627
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class SoulCollector : MonoBehaviour
  5. {
  6. public PlayerController player;
  7. private void Awake()
  8. {
  9. player = GetComponentInParent<PlayerController>();
  10. }
  11. private void OnTriggerEnter(Collider other)
  12. {
  13. Soul soul = other.GetComponentInParent<Soul>();
  14. if (soul)
  15. {
  16. if (player == null)
  17. {
  18. player = GetComponentInParent<PlayerController>();
  19. }
  20. soul.BeCollect(player.playerId);
  21. PoolManager.Instantiate(soul.getSoulEffect, transform.position);
  22. }
  23. }
  24. }