title: How to loop through unity gameobjects
body: <p>I want to make a script that loops through all game objects with the tag, <code>Enemy</code>
  I modified a code snippet from <a href="https://answers.unity.com/questions/50208/loop-through-all-objects-with-same-tag.html" rel="nofollow noreferrer">here</a>, and ended up with 2 errors.</p>
  <hr />
  <pre><code>Cannot Implicitly convert 'Unity.GameObject[]' to 'Unity.GameObject'
  </code></pre>
  <p>and</p>
  <pre><code>Error   CS1579  foreach statement cannot operate on variables of type 'GameObject' because 'GameObject' does not contain a public instance definition for 'GetEnumerator'
  </code></pre>
  <p>If anyone could tell me why this is happening or a solution to this I would be very grateful, thanks in advance!
  <em>Here is my code:</em></p>
  <pre><code>void FixedUpdate()
  
  {
      GameObject objects = GameObject.FindGameObjectsWithTag(&quot;Enemy&quot;);
      var objectCount = objects.Length;
      foreach (var obj in objects)
      {
          // Move the players accordingly
          //var rb = 
          Vector2 direction = (player.position - transform.position).normalized;
          obj.rigidbody.velocity = direction * moveSpeed;
  
      }
  }
  </code></pre>