title: Colliding in C# (Unity)
body: <p>I'm pretty new to C# and I'm currently developing a small 2D game. I have a script for the collisions so that I get a <code>Debug.Log()</code> whenever my character touches something. This is the script:</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class Collidable : MonoBehaviour
  {
      public ContactFilter2D filter;
      private BoxCollider2D boxCollider;
      private Collider2D[] hits = new Collider2D[10];
  
      protected virtual void Start()
      {
          boxCollider = GetComponent&lt;BoxCollider2D&gt;();
      }
  
      protected virtual void Update()
      {
          //Collision Work
          boxCollider.OverlapCollider(filter, hits);
          for(int i=0; i&lt;hits.Length; i++)
          {
              if(hits[i] == null)
                  continue;
            
              OnCollide(hits[i]);
  
  
              hits[i] = null;
          }
      }
      protected virtual void OnCollide(Collider2D coll)
      {
          Debug.Log(coll.name);
      }
  }
  </code></pre>
  <p>I would like to get only 1 console log whenever my character is, for example, picking up, therefore, touching a chest and get a message what he picked up, but for as long as the character is touching the chest, the Logs won't stop flying.
  How can I fix that?</p>
  <p>Thanks in advance</p>