FindGameObjectsWithTag only returning an array with one object?

So I’ve been trying to figure out a problem with my code in a previous post and my finding is that the GameObject I’ve created with FindGameObjectsWithTag only has a single GameObject in it at a time.

How can I get all the instantiated and tagged objects so I can then use their transform positions?

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {

	GameObject[] mountainTiles;

	bool debugTime = true;

	void Start(){
	}

	IEnumerator MountainDebug (){
		yield return new WaitForSeconds (5.0f);
	}

	void FixedUpdate () {
		PlayerMovement ();

	}

	void MountainChecker(){

		mountainTiles = GameObject.FindGameObjectsWithTag("Tile3");

		foreach (GameObject mountainTile in mountainTiles) {

			if(debugTime){
				Debug.Log (mountainTile.transform.position);
			}
			debugTime = false;
		}
	}

	void PlayerMovement() {
		StartCoroutine (MountainDebug());
		MountainChecker ();

	}
}

List m_MountainTiles = new List();
Foreach(GameObject o in GameObject.FindGameObjectsWithTag(“Tile3”))
m_MountainTiles.Add(o);

Your code works fine. I made a very small test class to check it with instantiated objects below.

I suspect the object your instantiating doesn’t actually have the tag when it’s instantiated. Check the new objects in the inspector to confirm ( you may not have updated the prefab’s tag (which is how I was able to replicate your problem).

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CountTags : MonoBehaviour {

    GameObject[] mountainTiles;

	void Update () {
        MountainChecker();	
	}

    void MountainChecker()
    {
        mountainTiles = GameObject.FindGameObjectsWithTag("Tile3");

        foreach (GameObject mountainTile in mountainTiles)
        {
                Debug.Log(mountainTile.transform.position);
        }
    }
}