# Z Order Sorting (.C3P Included)

0 favourites
• 5 posts
From the Asset Store
A master sorting Puzzle fun and addictive puzzle game! A challenging yet relaxing game to exercise your brain!
• I’ve hit a wall with Z Order Sorting in Construct3.

My questions is how do I handle Z Order Sorting for multiple objects in a layout. I am not a programmer so this concept is very new to me. So Ive broken down my approach to Z Order Sorting and documented it below with Gifs, Screenshots of Events and Ive also included the .C3P

The layout has the following objects

• Player
• Doorway
• Box (1 to many)

From my finding - it is easy if the Layout has a player and one object to Z Order Sort

And the Events look very basic as shown below

Now when the layout has two objects tThe Z Sorting stops working as intended.

and the Events look like this

And for a layout that has multiple objects that need to be Z Order sorted - the sorting is also not working.

• Thank you for the speedy reply . Correct me if I'm wrong, this is what I understand from your event's sheet

1. So you have a bunch of objects and have added them to a family group called 'Zorder'
2. Assuming you have added 'Skin' to the 'Zorder' group.
3. Then you have assigned an instance variable to the 'Zorder' family.
4. Assuming this instance variable is a number with an initial value '0'

There are two parts to the Events Sheet

A) Assigning a 'Zorder' to the Skin / Player's Y position

B) Sort by Zorder Value

A)In the first set of condition ---

• If the Skin is present on-screen and
• If the Skin is on the layer called 'Character'
• Then Set ZorderFamily to the Skin's Self.y

B)In the second set of conditions --

• If the Zorder (Family of Objects) is present on-screen
• If the Zorder (Family of Objects) is on the layer called 'Character'
• Then tell the system to sort Zorder (Family of Objects) by Sort Z order by Zorder (Family of Objects) Instance Variable 'ZorderFamily(number) (i.e the instance variable is assumed to be a number)

Does this sound correct?

Here is the Zordersort.cpx file with the updated code but it's failing to sort correctly

• ## Try Construct 3

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

Construct 3 users don't see these ads
• I'm sorry if my screenshot confused you, I was sorting the character's equipment at the same time

• Oh man! It finally works - THANK YOU SO MUCH!

I have uploaded the the Construct3 file so that anyone else facing this issue can download the working file and send props to