コード例 #1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         Debug.Log("Player Collided with Obstacle");
         OnObstacleCollision?.Invoke();
     }
 }
コード例 #2
0
ファイル: PlayerCollision.cs プロジェクト: Pbart/Proto-Type
 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();
     }
 }