Find Active gameobject with tag and store in a List/Array as a Transform?

Right now I have an array of GameObjects that all can individually become active or inactive based on player level progression using playerprefs. The active GameObjects in the array are not in order, so I need to find a way to store only the active GameObject’s positions so the player can travel between the available levels.

I have this at the moment:

void UpdateListOfWorlds()
{
GameObject[] availableWorlds = GameObject.FindGameObjectsWithTag("World");

        foreach (GameObject world in availableWorlds)
        {
            if (world.activeInHierarchy == true)
            {
                Debug.Log("Number of active Worlds: " + availableWorlds);            
            }
        }

}

This returns a number of logs equal to the number of active objects in the scene when UpdateListOfWorlds is used, which is good. But I’m unsure of how to actually get each object’s transform position and store that in an array that the player can travel between…if that makes sense?

you can grab that in array of the same size (or arraylist with add function) as the world and make it of Type Transform or Vector3 and assign that array in each iteration you already doing

             if (world.activeInHierarchy == true)
             {
                 Debug.Log("Number of active Worlds: " + availableWorlds); 
                 worldTransformsArr.add(world.transform.position);//Arraylist Positions
                 worldTransformsArr.add(world.transform);//Arraylist of transforms
                  //use either one of them as needed
             }

Regards

Shortly after, I realized that

GameObject[] availableWorlds = GameObject.FindGameObjectsWithTag("World");

could be set to

public GameObject[] availableWorlds;
  
void UpdateListOfWorlds()
{
availableWorlds = GameObject.FindGameObjectsWithTag("World"); 
}

And from there I can see that objects are being added to an array, in the exact order that they were unlocked, which is great!
Now it’s just a matter of calling a separate function that only allows travel between these GameObjects.

Use another list?

	void UpdateListOfWorlds()
	{
		GameObject[] availableWorlds = GameObject.FindGameObjectsWithTag("World");
		private List<GameObject> activeWorlds = new List<GameObject>();

		foreach (GameObject world in availableWorlds)
		{
			if (world.act == true)
			{
				activeWorlds.Add(world);
			}
		}
	}