2D Light as Field of View?

I’m trying to implement a standard FoV/LineOfSight feature in my 2D game using the URP 2D Renderer.

I thought I could use the new 2D Lights to create a simple FoV so I added a Point light to the player and the effect is good enough for what I’m trying to do:

However what’s missing is that the light cone/rays should stop when it hits an obstacle (eg. the blue walls). Currently the light just lays on top of everything. Is it possible using current 2D lights to configure it so that the light wont overlay the obstacles?

(link to gif if it doesnt show: Imgur: The magic of the Internet)

You have to add shadow casters to anything you want to block the light.

I added a ShadowCaster2D to an object and it creates a shadow but it doesnt block the light:

As you can see in the picture I still get vision behind the obstacle (the light passes through)

The ShadowCasters bounds matches the obstacles

I’d recommend looking up the actual API page, as it covers this:
https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@7.1/manual/2DShadows.html

I should also add, make sure your light source has it’s shadow setting set appropriately as well. It is what determines the effectiveness of the shadow casters (ie if they block all light or just some).

You need to do two things:

  1. In your PointLight2D Game Object, in the 2DLight component, increase the Shadow Intensity slider to 1 (away from 0)
  2. In your ShadowCaster2D component tick the SelfShadow box.

Does that do the trick?