Search Unity

Help trying to squeeze in both lights AND FoV in a 2D game

Discussion in '2D' started by dottonecioni, May 31, 2021.

  1. dottonecioni

    dottonecioni

    Joined:
    Jul 21, 2017
    Posts:
    8
    Hello lads,
    A few days ago I created a Field of View effect for my 2D top-down game following this tutorial. It works fine for me, but the big problem is that it requires you to use the URP 3D renderer for all the various "masking" effects, while I want to be able to use 2D lights in my scene. (If you don't want to watch the video, what I did was use the rendering options to create a series of "masks" that show or hide objects based on whether or not a custom-generated mesh is over them. I will upload my project for you to take a look at so you can see exactly how it works.) Is there a way to use both renderers, maybe using camera stacking, so that I can see the lights AND the FOV cone? Failing that, is there a way to make a FOV effect in Unity2D? Maybe use shaders? I'm really just open to any and all suggestions since I've been slamming my head against this wall of a problem to no avail for quite some time now. Attached is a screenshot of the FOV effect I've got working right now.

    Link to the project files.

    FOV pic.PNG
     
  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,514
    There's no out-of-the-box way of doing that. There's an asset with all those features, Smart Lighting, which has good reviews.
     
  3. dottonecioni

    dottonecioni

    Joined:
    Jul 21, 2017
    Posts:
    8
    Thank you for your reply, Lo-renzo, however I did find this post which tells of a "solution" to my problem. One that I haven't been able to get to work, though. So there HAS to be some way I can make this work... I'm just not good enough to come up with one.