0 Favourites

What is the 'sort Z Order' used for?

  • I am making a 'Pseudo-3D' game. So, some objects that are closer must cover the further ones. So, I've got this instance variable that determines their position based on the their Y coord.

    Then I sort their Z order with the instance variable and expect it to do its job.

    But it doesn't work the way I want it to, so I'm afraid I don't know what the purpose of this action really is.

  • That sounds like how it's supposed to work.

    There are ways that it may not work correctly, hotspots, event order etc.

    Post a capx for someone to test.

  • You can set the Z order directly in a sprite commands.

    In some of my games I have to reset the Z order after new objects are created that would be on top and sort Z command is useful for that.

    Sorting by Y coordinates may be tricky if your objects are moving around.

  • I put everything I want sorted in a family. Then give the family a family variable. Every however often, I set that variable to each object's Y coordinate. Then I run the sort command and sort it, ascending, by that value (note, the command has to use a variable and not some other value). Perfectly simple, works great so long as I have image points set up correctly. Any manual changes to the Z order are done immediately after that event.

    There's my full event. I narrow it down to what's on-screen and on the layer I want, set my variable, then sort. Then I have some manual adjustments after for different object types (Spriter objects).

  • RobertMKD

    Are the objects on different layers ? Are you using a family ?

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • The part where I set the 'Z Order instance variables' is working properly (I have already checked that in debug), while the 'sort Z Order' is in the same event together with the 'set instance variable' action.

    The objects are in a same layer and yes, I'm using a family.

  • Do me a little favour. I had this 'quirk' a year ago. The screen did not update. Place an (test) object somewhere. Give it animation frames. Loop it. Is the Z order updating fine now (it did back then on me). I suspect that you have not one object moving/animating on screen.

  • The screen's failing to update is a logical explaination, but I do have animating objects on screen, and they are also not properly ordered..

  • Okay guys, I've fixed it!

    First I was sorting the objects using 'On Created', and I had a separate 'every 0.1 sec' event that updated the Z orders of the objects that are moving.

    So, now instead of only updating the moving objects, I am updating all objects, and that's what fixed it

    Thanks to everyone!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
106 22,413
Stweve's avatar
Stweve
Unread hot topic
73 9,196
lolpaca's avatar
lolpaca
Unread hot topic
0 Favourites
Depth sorting - almost solved
62 5,164
lucid's avatar
lucid