SoulCollector.cs 587 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. 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. }
  22. }
  23. }