Open SecretPocketCat opened 2 years ago
Isn't this behavior expected considering the sprite exists in 3d?
Isn't what you're referring to as "z index" actually just the Z position in 3d?
Or am I misunderstanding something?
@lukors My issue is that only the parent.z scale affects the final z position, but not the transform of the sprite itself.
My opinion here is that this is a clear and compelling argument in favor of dedicated Transform2D
types. This behavior is very surprising to beginners, and just adds to the friction of trying to make 2D games using 3D transforms.
That would be great.
As a newcomer who just stumbled on this and spent some time figuring it out, here's how I would have expected this to work for 2D:
This would also be consistent with the docs in transform.rs, which mention z-ordering for translation but not for scale. As it is, it really is not clear at all how translation, scale, and child entities interact when it comes to z-index calculation. (Incidentally, is there a write-up about that somewhere, without looking through the source?)
I don't know how that would play with the larger implementation or 3D handling. It's just what would fit my initial, intuitive model.
Bevy version
0.6.1
Operating system & version
Win 11
What you did
Spawned a parented sprite and change the parent's scale.z to something other than 1.0
What you expected to happen
Z-index of a sprite wouldn't be affected at all or the transform of the sprite would affect it as well.
What actually happened
It's affected by the parent transforms
Additional information
Repro https://github.com/SecretPocketCat/bevy_issue_repro/blob/sprite_index_scale/src/main.rs (the expected order from bottom would be red, green, blue)