[SOLVED] Correct way to reorder child entities?

Hey guys,
I currently have a list of entities in a layout group that I want to reorder with script. I thought I’d be able to remove them with removeChild() and re-add them in the new order, but removeChild doesn’t seem to actually stop them from being rendered. The only way I’ve managed to get what I want is to clone all the children, destroy() the originals and then add the clones. This seems like too much work for something so simple. Is there a better way to do this?

Is this for the 2D UI canvas? Rather than destroying them, you could disable the entity instead.

1 Like

You can sort the children of the parent directly using standard Javascript Array.prototype.sort().

I made a small project to give example:


Thanks LeXXik! That’s just what I needed