Relative Z indexes do not carry through to scripts
CitrusWire opened this issue · 4 comments
Godot version:
3.2.3
OS/device including version:
Win 7
Issue description:
Relative Z-Indexes do not carry through to stand-alone script functions that are called from a parent.
This despite the fact that both the parent and the script have (default to) is_z_relative()
== true`
Steps to reproduce:
Parent scene:
-> Background sprite (z-index 0)
-> A scene (z-index 100) with a script attached calls a stand alone script that has a _draw()
call in it. That draw call will be placed underneath the background.
Minimal reproduction project:
Will produce if this is confirmed as a bug
@CitrusWire I don't understand exactly what's going on based on your description. Could you upload a minimal reproduction project, please?
Scene (a) has a script which calls Script (D). D calls the _draw() method and draws something onto screen. That something is below the background(Z), despite the fact that everything else in Scene (a) correctly draws on top of background(Z).
In that case, I can confirm that _draw() doesn't take relative z into account (I ran into it once, before 3.2.3)
godotrelativezbug.mp4
I've got a fuller explanation of how I'm seeing this issue in my small project in this video.
The fundamental issue is that there is no easy way, short of manually walking up the tree and adding up the z_index values to get the relative z depth in script. Even when chains of nodes all have Z is Relative set as true. Looking through the current implementation it seems that relative z is pretty implicit so maybe a get_relative_z method would be a good addition to Node2D similar to local/global transforms.