How can I fix my inconsistent light masking for my line of sight system?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TheSecondReal0

I’m making a multiplayer 2D game where each person has their own flashlight that they can toggle on and off. I’m trying to make it so that players can’t see other player’s flashlight light through walls. Right now I’m using light2D nodes set to add for the flashlights and a light2D node set to mask for the line of sight.

Here is an image I will use to describe the issue better:
A Screenshot from my game showing the bug

The player character is colored red. The flashlight of the player directly above the red player is showing correctly, as the red player cannot see it’s flashlight light when it goes behind the wall. It is working incorrectly for the 3rd player in the center of the circle-ish walls, as the red player can see the entirety of the flashlight.

Right now it is set up so that all of the lights are on the same cull layer with the LOS (line of sight) node on a higher z-index with the shadow color set to the background color. I have tried using a CanvasModulate node with the LOS, but that didn’t work and broke the entire LOS system entirely. Any help would be much appreciated.