title: Problems with Unity rhythm game if key is pressed and note is not on box then count as miss
body: <p>I'm making a rhythm game in Unity and so far I've got the basic functionality running. However I would like it so that if the user pressed a key when no arrow is on the box to count as a miss. To do this I added an else statement to <code>canbepressed</code>.</p>
  <p>This is my code so far:</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class NoteObject : MonoBehaviour
  {
  
      public bool canBePressed;
      // Start is called before the first frame update
      public KeyCode keyToPress;
  
      public GameObject hitEffect,goodEffect,perfectEffect,missEffect;
      void Start()
      {
          
      }
  
      // Update is called once per frame
      void Update()
      {
          if (Input.GetKeyDown(keyToPress)) {
              if (canBePressed) {
                  gameObject.SetActive(false);
  
                  //GameManager.instance.NoteHit();
  
                  if (Mathf.Abs(transform.position.y) &gt; 0.25)
                  {
                      GameManager.instance.NormalHit();
                      Instantiate(hitEffect, hitEffect.transform.position, hitEffect.transform.rotation);
                          
                      Debug.Log(&quot;Hit!&quot;);
                  }
                  else if ((Mathf.Abs(transform.position.y) &gt; 0.05f))
                  {
                      GameManager.instance.GoodHit();
                      Instantiate(goodEffect, goodEffect.transform.position, goodEffect.transform.rotation);
                      Debug.Log(&quot;Good!&quot;);
  
                  }
                  else {
                      GameManager.instance.PerfectHit();
                      Instantiate(perfectEffect, perfectEffect.transform.position, perfectEffect.transform.rotation);
                      Debug.Log(&quot;Perfect!&quot;);
  
                  }
  
  
              }
              else
              {
                  Debug.Log(&quot;Miss&quot;);
                  GameManager.instance.NoteMissed();
                  Instantiate(missEffect, transform.position, missEffect.transform.rotation);
              }
  
          }
      }
  
      private void OnTriggerEnter2D(Collider2D other)
      {
          if (other.tag == &quot;Activator&quot;) {
              canBePressed = true;
          }
      }
  
      private void OnTriggerExit2D(Collider2D other)
      {
          if (gameObject.activeSelf)
          {
              if (other.tag == &quot;Activator&quot;)
              {
                  canBePressed = false;
  
                  GameManager.instance.NoteMissed();
                  Instantiate(missEffect, missEffect.transform.position, missEffect.transform.rotation);
              }
          }
      }
  }
  </code></pre>
  <p>The problem this causes is that when you press a key it says MISS! for the other 3 like this:</p>
  <p><a href="https://i.stack.imgur.com/ISfRp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ISfRp.png" alt="enter image description here" /></a></p>
  <p>I'm not sure how to change it so that it says miss only for the one that is pressed. I'm guessing that it is because its <code>getkeydown</code> for all instead of one. How do I change it to be for each key?</p>