CanvasLayer does not display

Godot Version

v4.2.1.stable.official [b09f793f5]

Question

This is the first time I have used Godot. I’m a noob.

My game is located here: GitHub - jp31415926/godot_game: Testing godot game engine

My kids and I are playing around trying to write something like Five Nights at Freddy’s, except in a Sushi restaurant? Hey, as long as they are learning how to build a game and having fun, I don’t care. So I’m hacking something up for them to learn.

We are all learning Godot, if there are any blatant/stupid things in our approach, I’m very open to comments/criticism. Teach me! :slight_smile:

Problem: I’m displaying a background sprite and panning the viewport left and right when the mouse is moved left or right of the window. There are buttons on the left and right that move with the background image, as desired. I have placed a CanvasLayer at the same level as the background image and the Camera2D, and I want children of the CanvasLayer to stay stationary as the viewport pans left and right. However, when I debug the game, the child nodes of the CanvasLayer are not displayed at all. Perhaps they are drawn under the other things??? Changing the Z order of various nodes didn’t see to make much difference.

Hint: When I enable “Follow Viewport” in the CanvasLayer, then the children ARE displayed, but they pan with the background image (which is not what I want and why I am using CanvasLayer to begin with).

I’ve sure I am doing something wrong, but I can’t figure out what.

I appreciate any help.

TIA!

Make sure that the CanvasLayer.layer property is higher than 0 (by default is 1) If you have more CanvasLayers then change the layer of the one that has the buttons to be higher than the other ones.

Also, make sure that the buttons are inside the viewport (the blue rectangle in the 2D editor)

Check and check.

Layer is set to 1, and there is only one CanvasLayer.

The children of the CanvasLayer are all labels, and they are definitely located in the viewport window.

Thank you.

Does anyone else have any thoughts to offer on this problem, please?

Got it! Had to download and run it, but I worked it out! You['re putting your labels where your camera is, but because your items are in a different canvas layer, they need to be in the original blue square, like below!

1 Like

You got it! Thank you. I ended up just moving everything over to the blue rectangle and now it works great.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.