I'm trying to find objects with "Creature" tag and fill an GameObject array to get a Turn Order.
In one script I created this:
public PlayerOrder[] playerOrder;
public void CalculateTurnOrder()
{
    GameObject[] creatures = GameObject.FindGameObjectsWithTag("Creature");
    playerOrder = new PlayerOrder[creatures.Length];
    int index = 0;
    foreach (GameObject creature in creatures)
    {
        playerOrder[index].playerObject = creature;
        index++;
    }
    
}
void Start()
{
    CalculateTurnOrder();
}
Then I went and created a class for my array:
[System.Serializable]
public class PlayerOrder
{
    public GameObject playerObject;
    // For now I'm disabling these, same error.
    // public string playerName;
    // public int dexMod;
}
The problem is that, I can get creatures with GameObject[] creatures = GameObject.FindGameObjectsWithTag("Creature"); , and it successfully exits foreach loop if I store GameObject information inside a variable. I think my problem is filling array with playerOrder[index].playerObject = creature; is not correct, but I don't know better.
I'm just stuck.
