CanvasLayer disappears when anything else enters the camera

Godot Version

Version 4.3

Question

So I’ve been trying to add a HUD to my 2D game to just display some basics like a health bar, coin count, etc. I’ve looked around and saw that adding a CanvasLayer to my game seems to be the way to go.

Everything seems to be fine until any other object/texture enters the camera. When this happens it causes the HUD (CanvasLayer) to completely disappear. For example, the HUD will display correctly but the second my player sprite enters the camera, the HUD goes away.

This shouldn’t have anything to do with layering as I made sure my CanvasLayer and child node’s layers were higher than anything else. I’ve been stuck on this for quite awhile and haven’t seen anyone with a similar issue so it feels like some sort of bug

Set the layer to 99. And can you show a screenshot of your canvas layer?

1 Like

Yeah here’s a screenshot of me trying to display a default sprite in the top-right corner and there is nothing else on screen

1 Like

And here is what it looks like where the only difference is a player is in the camera view.


These two images were from the same game run. I had a character directly above the camera off-screen and just moved the character down into view and the sprite on my canvas layer disappears. On the right you can see my canvas layer has a layer of 99.

1 Like

So if you know your not changing a lot of stuff a bad but in my opinion pretty effective is just putting text in like the top left of the camera and setting the camera to stretch in game objects so it works on all resolutions and won’t break the “sudo-method” I use (Unless my methods actually good but I don’t think it is lol)

Okay that seems to be getting me somewhere. Getting rid of the canvaslayer (still not sure why this is happening to my canvaslayer) and attaching my UI sprites to the camera get them to appear, but after setting the camera to stretch, get the black bars on the side when I change the window size. Are there any other settings I may be missing or scripts to add to my camera?

What stretch mode are you using?

Have you tried using canvas_items?