> Heres an example of what Im trying to do. The problem is that the for each loop only runs once. So how do i repeat it?
>
>
>
You have the trigger once condition there, right?
If you remove it, it might not only trigger once..
I'm also wondering why you have the else statements, by the way..
I would just do it like this
system pick all z-order
> z-order move to layer "infront"
system pick z-order by comparison z-order.y+z-order.elevation > Playerbase.y
> z-order move to layer "Behind"
Thanks. I did that before, but what im trying to do at this point is to optimize my code to use less CPU, hence the trigger once conditions. What i dont want is for values to be set, layers to changed and zSorting done every tick.... For Example: The Z sorting could be done only when an object switches layer to either infront or behind. If im not doing that the Zsorting only will use about 10-20% CPU with lots of objects on screen. Sorting smart, I managed to get it down to 0.8% CPU for sorting, by only sorting only things that needs to be sorted, Like overlapping objects, only when they need to be sorted.