Hi there, I’ve some planes parented all together to another plane just to tour one by one like a common array purpose (sure there are another way, i.e. using groups, but is the one way I’ve seen till today).
One practice before I did exactly the same and using a For looping touring children by children right, in order.
But I don’t know why, this time it doesn’t in order. Somebody can explain me the polite/rules than use blender for it? By the name, older object created in the project …
I can use another loop to check within each plane a property to check and set the order/sequence but I think is not necessary because like I commented I works right in one older practice.
I put the minimal possible blend file to show you.
I don’t explain so good… What I need is to read children by children by order. Blender must have a criteria to take some children or any object previuos than next one…
To explain what I need… in my project I have a List (sometimes 1 element, 3, … maximun 20, depends of the moment) and the first parented object must show the first element in the List/Array, the second parented object the second element … . I know I can have to loops controlling each list but I wish to know to understand it how blender control it.
=Monster;16964
Always treat them as un-ordered list.
… but if you confirm that, I do not go crazy looking at this issue more
Just like I comment before in a previous practice its working in right order, I place tonight here the other practice to show you the ¿casuality?
Yes, you get a list of objects which seems to have an order.
But you can’t control the order of objects. Even if you get the same order on different game runs, you easily get another order when running on another OS, after changing the scene, or even when running the game in a different way (e.g. start with scene vs. switching to scene).
So the best is to treat it as un-ordered (= random). That will preserve you from making incorrect assumptions.
Beside that I do not understand the relation of the list (as mentioned above) with parenting of ?whatever.
Maybe you show an example of what you mean.
Like Monster said, you should treat the list as being unordered. I’m not sure how Blender sorts the objects in a children list - it might be in the order of their name (i.e. Child, Child.001, Child.002), or more likely in the order that they were parented, or whatever.
You shouldn’t rely on how Blender has it by default because, as you have experienced, that order can change (i.e. if you were to un-parent an object by mistake and re-parent it, the order might be altered drastically). I think it’s better to sort the list somehow, using a property (or even the object names, if desired) to determine indexes.
I have tried many combinations, Blender do something strange.
For example if I parent just a object and then the rest or the rest plus this parented object (doesn`t matter if it has been selected at the end or the middle), Blender record this object like first object.
Then if I clear all parents and select all together again (doesn’t matter the sort) and parent them, still recognize the previous mentioned object like first parented object, to fix it I must clear all parents, and parent one by one in the specific sort.
Anyway like you recomended I start to manage the sort with another loop to no get surprises the day of tomorrow and has better control. Thank you every one, really was a stupid question but I feeled like curious how it works. I place a .blend file to show I get it sorted in another practice like I comment in a previous post.
I would also like to understand how this works… not because of parenting, but because it interferes with transparent objects, and how they react when in front of each other… I got to this thread looking for this issue in the forums, but still haven’t figured it out… changing the name of the objects moves them up and down in the outliner, but the scene drawing doesn’t seem to follow the order of the outline… so far, my best guess is creation order, as I’ve managed to change the behavior of transparent objects by adding a new object to the scene, joining the transparent object to the new object (a cube, for example), and deleting the vertices of the cube, keeping the vertices of the joined mesh. this does change things… but not always as expected…
As written already there is no order within the collection of objects. The outliner shows alphabetical order as it is programmed to sort the objects to support you.
You should never depend on the order of game objects within a list as there is no guaranty to preserve it in any way.
@nestanqueiro: Your description looks like you have some other problems rather then the order of objects. I suggest to open a new thread explaining the issue you have.
the list seem not changeable directly .(also if there .append() and reverse() , not work)
the only way to change order(but ever “random”) is with -> setParent() removeParent() and endObject()
otherwise you have to do a your list, i think Agoose mean this:
own = cont.owner
fakeList = sorted(own.children, key=lambda ob: ob.name) # this return a new list of object
print(“real->”, own.children) #not changeable
print(“fake->”, fakeList)
This is what we said. It has no order. So you can’t sort it.
You need a NEW list with OWN sort criteria (e.g. objects name) As MarcoIt shows you. Have a look at the Python documentation (look for sort) for more details. (@MarcoIt: I would not name it fakeList as it is a real list )
I think I know where your confusion is coming from.
This is because when you print a game object or a list of game objects it prints the names not the default string as commonly used by Python (<KX_GameObject at 12345>). This easily leads to the assumption game objects are strings which obviously is not true. The ability to access game objects by name from a CListValue makes this incorrect assumption even stronger (this is one reason why I do not really like this lazy method - the other reason is it is not telling if a name is unique or not = more confusion).