What is the 'sort Z Order' used for?

Get help using Construct 2

Post » Mon Mar 20, 2017 8:43 pm

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.
B
18
S
6
Posts: 138
Reputation: 1,643

Post » Mon Mar 20, 2017 8:55 pm

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.
Image ImageImage
B
168
S
50
G
163
Posts: 8,223
Reputation: 105,065

Post » Mon Mar 20, 2017 9:07 pm

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.
Banned User
B
23
S
6
G
58
Posts: 1,229
Reputation: 34,540

Post » Mon Mar 20, 2017 9:38 pm

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.

Image

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).
Last edited by C-7 on Mon Mar 20, 2017 9:45 pm, edited 1 time in total.
B
103
S
38
G
19
Posts: 962
Reputation: 17,986

Post » Mon Mar 20, 2017 9:38 pm

@RobertMKD

Are the objects on different layers ? Are you using a family ?
B
33
S
18
G
27
Posts: 2,445
Reputation: 20,354

Post » Mon Mar 20, 2017 9:56 pm

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.
B
18
S
6
Posts: 138
Reputation: 1,643

Post » Mon Mar 20, 2017 10:16 pm

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.
B
33
S
18
G
27
Posts: 2,445
Reputation: 20,354

Post » Mon Mar 20, 2017 10:58 pm

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..
B
18
S
6
Posts: 138
Reputation: 1,643

Post » Mon Mar 20, 2017 11:12 pm

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!
B
18
S
6
Posts: 138
Reputation: 1,643


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 13 guests