SoulCollector.cs 571 B

1234567891011121314151617181920212223242526
  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. if (player == null)
  14. {
  15. player = GetComponentInParent<PlayerController>();
  16. }
  17. Soul soul = other.GetComponentInParent<Soul>();
  18. if (soul)
  19. {
  20. soul.BeCollect(player.playerId);
  21. }
  22. }
  23. }