By the GameObject FindWithTag (string tag); returns one active object with a tag. And I would stuff all the objects with this tag in Array. How is this possible?

    1 answer 1

    You will laugh, but in the list of GameObject methods immediately above the FindWithTag method is written the FindGameObjectsWithTag method, which returns a list of active GameObjects with a tag . Returns an empty list if no GameObject 's has been found.

    Example:

     using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { public GameObject respawnPrefab; public GameObject[] respawns; void Start() { if (respawns == null) respawns = GameObject.FindGameObjectsWithTag("Respawn"); foreach (GameObject respawn in respawns) { Instantiate(respawnPrefab, respawn.transform.position, respawn.transform.rotation); } } }