Adding child objects of parent to List

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

public class BoardManager : MonoBehaviour
{
    private List<Transform> pathFieldsPositions = new List<Transform>();
    private List<Transform> finishFieldsPositions = new List<Transform>();
    private List<Transform> homeFieldsPositions = new List<Transform>();
    private Transform pathFields;
    private Transform finishFields;
    private Transform homeFields;
    public GameObject player;


    private void Awake()
    {
        this.gameObject.SetActive(true);

        pathFields = this.transform.Find("PathFields");
        finishFields = this.transform.Find("FinishFields");
        homeFields = this.transform.Find("HomeFields");

        int childCountPathFields = pathFields.childCount;
        int childCountFinishFields = finishFields.childCount;
        int childCountHomeFields = homeFields.childCount;

        //Adding the children of the Path Fields game object to list
        for (int i = 0; i < childCountPathFields; i++)
        {
            pathFieldsPositions.Add(pathFields.GetChild(childCountPathFields - 1));
        }

        //Adding the children of the Finish Fields game object to list
        for (int i = 0; i < childCountFinishFields; i++)
        {
            finishFieldsPositions.Add(finishFields.GetChild(childCountFinishFields - 1));
        }

        //Adding the children of the Home Fields game object to list
        for (int i = 0; i < childCountHomeFields; i++)
        {
            homeFieldsPositions.Add(homeFields.GetChild(childCountHomeFields - 1));
        }

        Debug.Log("Finish fields positions count is:" + finishFieldsPositions.Count);
        Debug.Log("Path fields positions count is:" + pathFieldsPositions.Count);
        Debug.Log("Home fields positions count is:" + homeFieldsPositions.Count);

        for (int i = 0; i < homeFieldsPositions.Count; i++)
        {
            Debug.Log(homeFieldsPositions[i].transform.position);
        }
    }
}

I saved all child positions of 3 types of fields into Lists of Transform, but for some reaosn, when I want instantiate some game object on positions of items of these 3 lists, all game Objects are always instantiated on a one single component of lists, so all of them are at the same position of one Transform component from the lists.
What am I doing wrong here?
Thanks a lot for the help

Use code tags, it’ll make your code easier to read, also will prevent your code from mangling your post (like, your [ i ] made the remainder of your post italics, for example)

Use code tags. That’s your first mistake.

Second, I’m confused as to what you are trying to do. Your for loops suggest you want to start from child 0 and go to the max child.

But then when you call GetChild, instead of using “i” you use childCountHomeFields -1, which means you’ll always get the last child. You are always going to get the same child over and over again.

Hello,sorry for mistakes, its my first times posting here, hope you dont blame me :slight_smile:

Problem solved, I should have just put the variable i into code, and not those ChildCounts.

Thanks a lot for your help and time!