Пример #1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         Debug.Log("Player Collided with Obstacle");
         OnObstacleCollision?.Invoke();
     }
 }
Пример #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Collectible")
     {
         //Fire the OnCollectableCollision event
         OnCollectableCollision?.Invoke();
         Destroy(collision.gameObject);
     }
     if (collision.tag == "Obstacle")
     {
         //Fire the OnObstacleCollision event
         OnObstacleCollision?.Invoke();
     }
 }