Hey! I’ve been trying to make a simple game where everything is dark, and the player is at the center of a light. I have tried to follow multiple tutorials, but I can’t seem to get any of them to work. So far, I have a colorRect colored black as the background and a pointLight2D with a circle texture. When the tutorials drop in the texture, the texture shows up on the map, but mine doesn’t. Any Ideas?
Hmm. I couldn’t get it to work with a ColorRect either, but got it working with a MeshInstance2D in the background and a CanvasModulate node, which tells it what color to use where no light is reaching.
It works well, but when I add another colorRect (for the player), because of the canvasModulate, the colorRect also turns black. When I try to fix this by putting either the background or the player in a canvasLayer (putting the player in a canvasLayer set to 1 works best), the camera I put as a child node to the player stops completely moving with the player, and it looks as if the player is moving on the canvasLayer and the main screen. My player code is thus (the frame variable is for testing):
I fixed it. I put the ColorRect only in the separate canvasLayer and added a script to the canasLayer that changed the canvasLayer’s offset to be equal to the player’s global location. I also had it get the size of the viewport and move the colorRect to center of the screen.