Static background independent of camera position

Godot Version



How do I make a static background that doesn’t move when the camera moves? I feel like this should have an easy answer, but I somehow have been unable to find it anywhere.

I’ve tried putting a TextureRect and a Sprite as a child node of the Camera and it works well if the camera instantly moves to another place in a single frame. However, if I animate the camera, for example using a Tween, then the background follows the camera with some delay, it doesn’t perfectly match the camera position until the animation ends.

How do I fix this?

Here’s my node configuration:


And I’m using this Tween to move the camera:

var tween = get_tree().create_tween()
tween.tween_property(self, "position", Vector2.ZERO, 0.2).set_trans(Tween.TRANS_LINEAR)

Thanks a lot!

Add a canvaslayer, reduce the layer number until it’s behind everything, and then add a background as a child of it.

Thanks! CanvasLayer is exactly what I was missing!
In my case it was a bit more complicated because it’s not actually a background, but an overlay that I wanted to appear on top of the game, but below the GUI.
I solved it by using different CanvasLayer’s for each group of nodes (gameplay elements on default 0 layer, overlay elements inside a CanvasLayer on layer 1 and GUI elements inside a CanvasLayer on layer 2).

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