Search code examples
unity-game-enginelight

Unity2D get light to go behind objects


So i have been experimenting with the URPA 2D lights lately. And i have a scene where you can basicly just move and go behind pillars, but the light stays on top of the pillars.

How can i get the light to go behind the pillars?

Image One

Image Two

enter image description here

The pillars work basicly that when you go above a line where you should be behind a pillar if you moved towards one, a copy of the pillar overlays the original pillar and is on a higher layer than the player.

Thank you in advance.


Solution

  • Try using multiple render layers e.g. "Foreground" and "Background" and render each object in your room on one of these layers and have the light-beam only effect the background for example. If your light-beam is only a sprite you can make it even simpler as you'd only need to place it into the "Background" layer and it would be rendered behind the "Foreground" layer. Hope this sheds some light on the problem 😀