#z_index layering issues

1 messages · Page 1 of 1 (latest)

sullen estuary
#

I'm having problem layering z_indexs correctly, in my game I have a player entity and a prop.
For demonstrational purposes, the player can walk through the prop in question.

The intended behaviour is that when the player is below a prop's y level, they should be drawn infront of it;
But if they are above the prop's y level they should be drawn behind it.

However I'm having trouble implementing this correctly and the prop is always drawn infront of the player.

Both props have z_index set to 1, z_as_relative set to false and y_sort_enabled set to true.
I've tried manually adjusting the z_layering by using the y value of the player's position, but due to the z_layer variable clamp and the fact it uses integers instead of decimals, the z_layer range has proven to be too small to use effectively.

I feel like I'm doing something wrong here and I'm not sure how to layer z_index by the character's y level correctly, does anyone know what I'm doing wrong?

stray blade
#

Are the player and props under the same parent node?
I think for ysort to work, it has to be on for:

  1. Both props
  2. The player
  3. The overarching parent should also have an option for children to have ysort
stray zealot
#

It's the parent that y-sorts the children, so you only need to turn on y_sort_enabled on the parent (the scene root, for example)

#

For y-sorting to work, the origin of y-sorted objects needs to be at the bottom, the point where they "touch the floor"

#

If the origin/pivot is in the center of sprites, objects of different heights won't be sorted correctly