Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Help with hiding Light2d under a sprite (URP)

Discussion in '2D' started by lordumbilical, Jun 15, 2023.

  1. lordumbilical

    lordumbilical

    Joined:
    May 24, 2020
    Posts:
    38
    It seems fairly simple, but I just can't get a Light2D to be hidden when an object moves over it. If anyone has time, can they possibly read through and correct my assumptions?:

    1. I have 2 sorting order layers. Default, and Hider. Hider is below Default in order, which I understand means hider will be on top (and that how it works when I test with sprites moving around. Indeed, swapping the order makes no difference with the light anyway).
    2. My light: Target Sorting Layer = Default
    3. My hiding object has a sprite renderer with Sorting Layer = Hider.
    4. When sprite goes on light, light should be occluded.
    5. No, light shines upon the sprite, exactly the same as if light and sprite are on same sorting layer.

    I'm sure I'm doing something wrong. Any help appreciated.
     
  2. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    2d lights cant be blocked by sprites with unity basic features

    need hard shader work to pull it off
     
  3. lordumbilical

    lordumbilical

    Joined:
    May 24, 2020
    Posts:
    38
    That's a shame. Ok, I guess I manually need to do detection and turn them off manually.
    Thanks.
     
  4. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    its a big problem, for example if the light range is larger than your sprite it will look very bad if the light just disapears