title: Input.GetMouseButtonUp is not reliable. (Unity)
body: <p>I am developing a 2D game in unity. One of the features in the game is to shoot projectiles using the left click of the mouse. Upon releasing the left click the projectile gets fired with certain amount of force that depends on how long the player held the left click. </p>
  
  <p>The problem is that sometimes when I release the left click the game doesnt seem to detect it and the release portion of the code doesnt get executed until I click and release again. I may not sound like a big problem but input reliability will play a fundamental role in this game. </p>
  
  <p>So, is there any way to make mouse input more realiable? I have already tried using Input.GetMouseButtonDown and different kinds of conditionals in order to make it more reliable, but it hasnt worked out. Thank you in advance!</p>
  
  <p>Here is the code I am using:</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class ShootPlasma : MonoBehaviour {
  
      //prefab
      public Transform bulletPrefab;
  
      //Reloading variables:
      public int numberOfBullets;
      private int numberOfBulletsRecord;
  
      private bool canShoot=true;
  
      public float timeToReload;
      private float timeToReloadRecord;
  
      //direction and bullet Speed variables:
      Transform sightPosition;
      public Vector3 SpawnRiseVector;
      private Vector2 direction;
  
      public float bulletBoost;
      private float bulletBoostRecord;
      public float MAX_BOOST;
  
  
      //Arrow Guide
      public Transform aimingArrow;
  
      //Helper variables;
      private CharacterController2D charControllerScript;
  
  
      void Start () {
  
          timeToReloadRecord = timeToReload;
          numberOfBulletsRecord = numberOfBullets;
          charControllerScript = transform.parent.GetComponent&lt;CharacterController2D&gt; ();
          bulletBoostRecord = bulletBoost;
  
          sightPosition = GetComponent&lt;Transform&gt; ();
          aimingArrow.GetComponentInChildren&lt;Renderer&gt;().enabled=false;
      }
  
      // Update is called once per frame
      void FixedUpdate () {
  
          if(numberOfBullets&lt;=0){
              canShoot=false;
              if(!canShoot){
  
                  timeToReload-=Time.deltaTime;
  
                  //if the waiting time has ended restart variables.
                  if(timeToReload&lt;=0.0f){
                      canShoot=true;
                      timeToReload=timeToReloadRecord;
                      numberOfBullets=numberOfBulletsRecord;
                  }
              }
          }
  
  
      ////////////////////////////////// SHOOTING CODE ////////////////////////////////////////////
          /// 
          /// MOUSE DOWN
          /////////////////////////////////////////////////////////////////////////////////////////
          else if(Input.GetMouseButton(0)&amp;&amp; canShoot &amp;&amp; !Input.GetMouseButtonUp(0)){
  
              //show the Arrow Guide:
  
              if(aimingArrow.GetComponentInChildren&lt;Renderer&gt;().enabled!=true){
                  aimingArrow.GetComponentInChildren&lt;Renderer&gt;().enabled=true;
              }
  
              //calculate the distance between the mouse and the sight;
              Vector3 mousePositionRelative=Camera.main.ScreenToWorldPoint(Input.mousePosition);
              direction= new Vector2(mousePositionRelative.x- sightPosition.position.x,
                                     mousePositionRelative.y- sightPosition.position.y).normalized;
  
              //If Y is less or equal 0:
              if(direction.y&lt;=0.0f &amp;&amp; direction.x&gt;=0.0f){
                  direction=new Vector2(1.0f,0.0f);
              }
              else if(direction.y&lt;=0.0f &amp;&amp; direction.x&lt;0.0f){
                  direction=new Vector2(-1.0f,0.0f);
              }
  
  
              //Rotate the aiming arrow
              if(charControllerScript.facingFront){
                  if(direction.x&gt;=0.0f){
                      aimingArrow.rotation=Quaternion.Euler(new Vector3(0.0f,0.0f,(Mathf.Asin(direction.y/direction.magnitude))*Mathf.Rad2Deg));
                  }
                  else if(direction.x&lt;0.0f){
                      aimingArrow.rotation=Quaternion.Euler(new Vector3(0.0f,180.0f,(Mathf.Asin(direction.y/direction.magnitude))*Mathf.Rad2Deg));
                  }
              }
              else if(!charControllerScript.facingFront){
                  if(direction.x&gt;=0.0f){
                      aimingArrow.rotation=Quaternion.Euler(new Vector3(0.0f,180.0f,(Mathf.Asin(direction.y/direction.magnitude))*Mathf.Rad2Deg));
                  }
                  else if(direction.x&lt;0.0f){
                      aimingArrow.rotation=Quaternion.Euler(new Vector3(0.0f,0.0f,(Mathf.Asin(direction.y/direction.magnitude))*Mathf.Rad2Deg));
                  }
              }
  
  
              Debug.Log(direction);
  
  
              //Charge
              bulletBoost+=Time.deltaTime*bulletBoost;
              if(bulletBoost&gt;=MAX_BOOST){
                  bulletBoost=MAX_BOOST;
              }
          }
  
          ///////////////////////////////////////////////////////////////////////////////////////////////////
          /// MOUSE UP
          /// ///////////////////////////////////////////////////////////////////////////////////////////////
          else if(Input.GetMouseButtonUp(0)&amp;&amp; canShoot &amp;&amp; !Input.GetMouseButton(0)){
  
              //Hide the Arrow Guide:
  
              if(aimingArrow.GetComponentInChildren&lt;Renderer&gt;().enabled!=false){
                  aimingArrow.GetComponentInChildren&lt;Renderer&gt;().enabled=false;
              }
  
  
              //Fire
              var shootPrefab= Instantiate(bulletPrefab,sightPosition.position+SpawnRiseVector,Quaternion.identity) as Transform;
  
              shootPrefab.GetComponent&lt;Rigidbody2D&gt;().AddForce(direction*bulletBoost);
              bulletBoost=bulletBoostRecord;
  
              //Reduce the Ammo by one:
  
              numberOfBullets-=1;
          }
      }
  }
  </code></pre>