How to setup foreground objects in scene (and in parallax scrolling)?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By molni

Hi,

I’m using GODOT3 (newcomer) and know that Z index is using for controlling order of nodes in which they are render on the scene.
But it does not work for me. Tried Z-index, no changes. Tried rearranging layers, but no change…
I have always player on the top layer. Need to setup sprite of parallaxlayer to be above player’s sprite on the scene.

https://imagebin.ca/v/3xRhKwPFx87c

:bust_in_silhouette: Reply From: markopolo

This is probably because ParallaxBackgrounds are also CanvasLayers. CanvasLayers are always drawn completely “in front of” or completely “behind” other CanvasLayers (i.e. z layers are always “within” a canvas layer). I think of it as sort of a separate kind of z layering, if that makes sense.

There’s a default CanvasLayer that your player and walls are being drawn to: layer 0. The two ParallaxBackground objects you have are different canvas layers. CanvasLayers created in the editor default to drawing to layer -1, which explains why they’re always behind the player, even when you’ve set z values differently.


TL,DR: change the Layer property on your ParallaxBackgrounds to get them in front of or behind other layers. I also recommend reading the CanvasLayer docs :slight_smile:

Hi Marcopolo,

it is like a wonder, but I managed it to work almost athe same time as I get your email. :slight_smile:

Here is screen:
https://imagebin.ca/v/3xiYduj9wria

In parallaxbackground type of node , there is “canvaslayer” setting when I changed it from -1 to 0 and it is perfectly now (in front of scene).

THANK YOU@!

molni | 2018-04-08 21:22

funny how often that happens :smiley: glad you got it figured out!

markopolo | 2018-04-08 21:25