0 votes

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
Here are my layers on the screenshot

in Engine by (15 points)

1 Answer

0 votes
Best answer

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 :)

by (629 points)
selected by

Hi Marcopolo,

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

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@!

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.