title: make a gameobject move to another gameobject that was selected by mouse click?
body: <p>Im currently making a turn based type of game however im stuck figuring out how to move the player to the position of the enemy that was chosen.</p>
  
  <p>This is the player script with the positions of the enemies.</p>
  
  <pre><code> void Update()
   {
       if ((Input.GetKeyDown("1")) &amp;&amp; (BattleFlow.playerTurn == 1)) // attack monster 1
       {
           BattleFlow.currentDamage = 40;
           GetComponent&lt;Animator&gt;().SetTrigger("PlayerMelee");
           GetComponent&lt;Transform&gt;().position = new Vector2(-4.78f, 3.68f);
           StartCoroutine(playerAttack());
  
       }
       else if ((Input.GetKeyDown("1")) &amp;&amp; (BattleFlow.playerTurn == 1)) //  attack monster 2
       {
          GetComponent&lt;Animator&gt;().SetTrigger("PlayerMelee");
          GetComponent&lt;Transform&gt;().position = new Vector2(-4.45f, 1.77f);
         StartCoroutine(playerAttack2());
      }
   }
  </code></pre>
  
  <p>The player can move to the location of monster 1 however the script for monster 2 doesn't work. The player still goes towards the direction of monster 1 even though I clicked monster 2.</p>
  
  <p>This is the code for the mouse click which I placed on the enemy script.</p>
  
  <pre><code>// Update is called once per frame
   void Update () {
   void OnMouseDown()
       {
           Debug.Log(gameObject.name);
           BattleFlow.selectedEnemy = gameObject.name;
  
       }
  </code></pre>