Advertisement
Crazist

Collision

Aug 18th, 2022
668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. public class CollisionComponent : MonoBehaviour
  2. {
  3.     private Action collectCoin;
  4.    
  5.     public bool IsCoinsInRadius { get; private set; }
  6.     public void OnTriggerEnter(Collider other)
  7.     {
  8.         var coin = other.gameObject.GetComponent<Coin>();
  9.         if (coin)
  10.         {
  11.             coin.Hide();
  12.             collectCoin.Invoke();
  13.         }
  14.     }
  15.    
  16.     public void AddAction(Action _collectCoin)
  17.     {
  18.         collectCoin = _collectCoin;
  19.     }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement