title: Unity C# Input.GetMouseDown(1) only happening once in update function
body: <p>so i've been working on some code for a game in Unity and i am using the Input.GetMouseButtonDown(1) function. However, it only works the first time i press the left click in the game and no other times after that. The code for the player controller where it's used is below:</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.UI;
  
  public class PlayerController : MonoBehaviour {
  
  public float speed;
  public Transform enemy;
  public Transform shot;
  public GameObject shotObj;
  public Text scoreT;
  public Text timeT;
  public Text roundT;
  public float health;
  public float damageTaken;
  public Vector3 lookPoint;
  public float shotSpeed;
  
  private Camera mainCamera;
  private int round = 1;
  private int tempRound = 0;  
  private float time = 300;
  private bool win = false;   
  private bool allowShoot;
  private EnemyController enemyScript;
  private ShotController shotScript;
  private bool tempImune = false;
  private int targetTime;
  private int score = 0;
  private int defeatedEnemy = 0;
  private GameObject enemyObj;
  
  //coroutine
  IEnumerator Pause(float timE)
  {
      allowShoot = false;
      //time since the object was created
      float start = Time.realtimeSinceStartup;
      //sets the game to slow down to 0 movement
      Time.timeScale = 0.0f;
      //loops until start up time is less than start time + pause time
      while (Time.realtimeSinceStartup &lt; start + timE)
      {
          //returns null from the subroutine and restarts the subroutine at this point after null (0) time has passed
          yield return null;
      }
      //sets the gamne to be running at normal speed
      Time.timeScale = 1.0f;
      allowShoot = true;
      if (timE == 5.0f)
      {
          roundT.gameObject.SetActive(false);
      }
  }
  
  void Start () {
      //center mouse
      Cursor.lockState = CursorLockMode.Locked;
      Cursor.lockState = CursorLockMode.None;
      //set camera to be the camera in the scene (should only ever be one camera in the scene)
      mainCamera = FindObjectOfType&lt;Camera&gt;();
      //set default text values
      scoreT.text = "Score: 000000";
      timeT.text = "Time Left: 600";
      roundT.text = "Round: " + round;
      //pause game before first round begins
      StartCoroutine(Pause(5.0f));
  }
  
  void Update () {
  
      //looka at mouse script
      Ray cameraRay = mainCamera.ScreenPointToRay(Input.mousePosition);
      Plane ground = new Plane(Vector3.up, Vector3.zero);
      float rayLength;
  
      if (ground.Raycast(cameraRay, out rayLength))
      {
          lookPoint = cameraRay.GetPoint(rayLength);
          transform.LookAt(new Vector3(lookPoint.x, transform.position.y, lookPoint.z));
      }
  
      //enemy spawner check and win criteria check
      if (defeatedEnemy != 45)
      {
          if (round != tempRound)
          {
              spawnEnemy();
              roundT.gameObject.SetActive(true);
              if (round == 5)
              {
                  roundT.text = "Round: " + round + "(Final Round)";
              }
              else
              {
                  roundT.text = "Round: " + round;
              }
              StartCoroutine(Pause(5.0f));
          }
      }
      else
      {
          win = true;
      }
  
      //timer and win check
      if (health == 0f)
      {
          win = true;
      }
      if (!win)
      {
          time -= Time.deltaTime;
          timeT.text = "Time Left: " + time;
      }
      else
      {
          if (health == 0f)
          {
              roundT.gameObject.SetActive(true);
              int finalScore = Mathf.RoundToInt(score * ((time / 2) / 10));
              roundT.text = "To Bad, You Loose! Score = " + finalScore;
              Debug.Log(finalScore);
              StartCoroutine(Pause(99999f));
          }
          else
          {
              roundT.gameObject.SetActive(true);
              int finalScore = Mathf.RoundToInt(score * ((time / 2) / 10));
              roundT.text = "Congratulations! Score = " + finalScore;
              Debug.Log(finalScore);
          } 
      }
  
      //movement controlls
      if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
      {
          transform.Translate(new Vector3(0.0f, 0.0f, speed * Time.deltaTime));
      }
      if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
      {
          transform.Translate(new Vector3(-speed * Time.deltaTime, 0.0f, 0.0f));
      }
      if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
      {
          transform.Translate(new Vector3(0.0f, 0.0f, -speed * Time.deltaTime));
      }
      if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
      {
          transform.Translate(new Vector3(speed * Time.deltaTime, 0.0f, 0.0f));
      }
      //shoot controll
      if (allowShoot)
      {
          Debug.Log("shot allowed");
          if (Input.GetMouseButtonDown(0))
          {
              //var spawnShot = Instantiate(shot, this.transform.position + new Vector3(0.0f, 0.0f, 0.5f), this.transform.rotation);
              //shotScript = shotObj.GetComponent&lt;ShotController&gt;();
  
  
  
              //if (shotScript.enemy)
              //{
              //    Debug.Log("enemy found");
              //    enemyScript = shotScript.enemy.GetComponent&lt;EnemyController&gt;();
              //    if(enemyScript.health &lt;= 0.0f)
              //    {
              //        score += 20;
              //        defeatedEnemy += 1;
              //        scoreT.text = "Score: " + score;
              //        Debug.Log("enemy killed : " + defeatedEnemy);
              //    }
              //}
              Debug.Log("mouseDown");
              int layermask = 1 &lt;&lt; 8;
              RaycastHit hit;
              if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity, layermask))
              {
                  enemyObj = hit.transform.gameObject;
                  enemyScript = enemyObj.GetComponent&lt;EnemyController&gt;();
                  Debug.Log("hit");
                  //hit.transform.SendMessage("HitByRay");
                  if (enemyScript.health == 0f)
                  {
                      Destroy(hit.transform.gameObject);
                      score += 20;
                      defeatedEnemy += 1;
                      scoreT.text = "Score: " + score;
                      Debug.Log("enemy killed : " + defeatedEnemy);
                  }
              }
          }
      }
  
      //enemy existance check
      if (GameObject.Find("Enemy(Clone)") == null)
      {
          round = round + 1;
      }
  
      if (tempImune)
      {
          if (Mathf.RoundToInt(time) == targetTime)
          {
              tempImune = false;
          }
      }
  }
  
  void spawnEnemy()
  {
      tempRound = round;
      for (int i = 1; i &lt;= round * 3; i++)
      {
          var spawnEnemy = Instantiate(enemy, new Vector3(Random.Range(-14.5f, 14.5f), 0.25f, Random.Range(-6f, 6f)), Quaternion.identity);
      }
  }
  
  void OnCollisionEnter(Collision col)
  {
      if (col.gameObject.tag == "Enemy")
      {
          if (!tempImune)
          {
              health = health - damageTaken;
              Debug.Log(health);
              tempImune = true;
              targetTime = Mathf.RoundToInt(time) - 1;
          }            
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Any help with this would be greatly appreciated as it's for a school project. Thanks.</p>