I have a simple trail effect. I have a script attached to Line2D as follows:
export (int) var max_length = 20
var p = get_parent().global_position
if len(points) > max_length:
Scene tree is as follows:
Or I can create the scene tree this way:
It makes no difference which way I construct the scene tree. Line2D always renders on top of the Polygon2D.
When I comment out the line with
set_as_toplevel(true), the problem is fixed (i.e., the draw order is respected - the Line2D is drawn either in front of or behind Polygon2D). But I need
set_as_toplevel(true) to make the transformations work.
Why does this happen? How do I fix this?