Get a list of children (in order)

I would like to have a list of all the children of Player, and have all of the objects in the list have like a number or something to indicate what order they are, 1st… 2nd… and such, you know?

(javascript (unityscript) pls)

If I got you correctly I think that what you’re looking for is basically in my P.S. section of my answer HERE.

Then when you find in that way every child of that object you assign them to some sort of Dictionary or whichever container and add them #1 - which indicates direct child. Then you repeat that code for every child and find their child and add them to that Dictionary with #2 (it can be int value or whatever you like, doesn’t matter), and so on and so forth, if no child was found for all of them then continue with whatever you want to do with them.

I believe you’ll be able to convert those few lines of code yourself to javascript, if not let me know.

P.S. Update to your updated question, here is how should you use that code that I’ve shown you in that link:

    Transform par = transform.parent;
    int childCnt = par.childCount;
    for (int i = 0; i < childCnt; i++)
    {
        Transform childX = par.GetChild(i);
        if (childX == transform)
        {
            //do your stuff
            // use "i" for your number
            //if you want your "i" to start from 1 then add +1 to it before you'll be doing your stuff
            break;//you can use break in the end here to break the rest of the loop, because you no longer need it from what you've specified
        }
    }

P.P.S. Here you go:

var parent : Transform;
var childCnt : int;
function Start () 
{
    parent = transform.parent;
}
function Update () 
{
     childCnt = parent.childCount;
     for (var i : int = 0; i < childCnt; i++)
     {
          var childX : Transform = parent.GetChild(i);
          if (childX == transform)
          {
              //do your stuff
              break;
          }
     }
}

Now if the parent can change as well then move line #5 to line between #8-9 or 9-10. If the number of child can’t change and parent can’t change then move whole thing from Update to Start function and just save your Integer value from there and then do with that integer whatever you want in your Update function.