Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Question 2D lighting, cast shadows only from some lights

Discussion in '2D Experimental Preview' started by Panzer_Ihnen, May 7, 2020.

  1. Panzer_Ihnen

    Panzer_Ihnen

    Joined:
    Jan 20, 2017
    Posts:
    7
    I have a gameobject with a shadow caster 2d. I want to put a light inside that game object that is not affected by that shadow caster 2D but by others. It's possible?
     
  2. MrPaparoz

    MrPaparoz

    Joined:
    Apr 14, 2018
    Posts:
    157
    You need to define a new Sorting Layer (It's on SpriteRenderer component). Then in your Light2D change which sorting layers light affects.
     
  3. Panzer_Ihnen

    Panzer_Ihnen

    Joined:
    Jan 20, 2017
    Posts:
    7
    I don't get it to work, I have the gameobject with the shadowcaster in the "characters" layer and the target sorting layers of the light 2D in "ground", but the shadowcaster still affects this light
     
  4. Panzer_Ihnen

    Panzer_Ihnen

    Joined:
    Jan 20, 2017
    Posts:
    7
    I believe that the "shadow caster 2D" is not linked to the "Sorting Layer" of the "Sprite Renderer" and is affected by all the lights. Any suggestions?
    luces1.jpg luces2.jpg luces3.jpg luces4.jpg
     
  5. TheRev433

    TheRev433

    Joined:
    May 3, 2020
    Posts:
    1
    Hi,

    Did you get any idea to do that?
    I'm also trying to figure it out but I haven't be able to do it.
     
  6. Panakvina

    Panakvina

    Joined:
    Mar 17, 2021
    Posts:
    2
    Hi, I don't know why, but Shadow Caster doesn't work, when some light on scene hasn't got Default target sorting layer checked.