kuligs2
It's a bit ugly...
Maybe my screenshots of the game will help explain this.
ParentNode(Night Market Roof)
-- ChildNode(Light on the Roof)
Both parent and child nodes are components that serve different purposes.
Parent node's role:
When the player walks behind the parent node, the parent node becomes transparent, mainly used for houses/roofs/etc. in this 2D top-down game. (This process is an animation)
Child node's role:
Lights which are visible at certain times of the day.
Most of the time they are independent of each other, but when the light is inside the parent node (such as a light on a roof), if the player walks behind the roof, the light should also be invisible. (Changing the parent node's modulate will not affect the energy of the child light2D node)
Currently my solution is:
ChildNode(Light) changes its energy in the _process
function according to real-time conditions. So I added some extra logic in it: Change energy according to get_parent().modulate.a
, the disadvantage of this solution is that it must be the first-level child of the parent node, maybe it will cause some problems in the future.