Search Unity

Best way to do a top down 2D cone light

Discussion in 'Scripting' started by EMOTION-THEORY, Oct 24, 2013.

  1. EMOTION-THEORY

    EMOTION-THEORY

    Joined:
    Jul 16, 2013
    Posts:
    83
    Hey everyone,

    I'm working on a 2D game. It's a top down game using an orthographic camera. All graphics are textures drawn onto quads and are currently set to unlit.

    I need to make a lighthouse with a spotlight that spins. The scene should be dark, and the things that are in the spotlight should be lit.

    How would I do a cone / spot light that illuminates the 2D quads?
     
  2. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Perhaps you could make a texture in Photoshop that has a section designated as the cone. This section, would be much more transparent tan the rest of the texture. Place texture at light house pos and rotate. Only the sprites, that a under the cone, will be clearly visible.
     
  3. EMOTION-THEORY

    EMOTION-THEORY

    Joined:
    Jul 16, 2013
    Posts:
    83
    That wouldn't really work unless the texture is ginormous and covers the entire scene, which doesn't feel practical.
     
  4. zombie_psy

    zombie_psy

    Joined:
    Oct 9, 2012
    Posts:
    62
    how bout taking the cone, squashing it inward to the lighthouse, simultaneously while making the outward edge bigger.

    That way it will give the illusion that the light cone is spinning toward your direction, then when the light is supposedly facing you, you can have the cone light fade out and then flash the camera with a lens flare type of thing, then do the reverse on the other side. Then repeat over and over.
     
  5. Kirlim

    Kirlim

    Joined:
    Aug 6, 2012
    Posts:
    126
    Making light effects with unlit shaders.... you will not have many possibilities there. The hint that renman gave is the simplest one (but you don't want to use it on mobile). Note that it is is not necessarily a huge texture to cover the whole scene - only what the camera sees. You can try to optimize by using a mesh with some kind of translucent black color instead of a texture, but this can get tricky.

    Or you can simply turn lights on, put a real spotlight and see if performance is acceptable. Other tricks may use post processing or making special shaders, and they are all kinda of a pain.
     
  6. EMOTION-THEORY

    EMOTION-THEORY

    Joined:
    Jul 16, 2013
    Posts:
    83
  7. Pnvanol

    Pnvanol

    Joined:
    Jan 11, 2016
    Posts:
    115


    Package is no longer up, know any alternative ?
     
    renman3000 likes this.