I'm creating 2D side scrolling game with Unity, and i want to add feature where the player come into a cave, then all going dark, the player turn on the flash light, so the player can see around ( With limited range )

I have done creating that by setting all object color to Black, and if the light is touching the object, the object color turned to White, but the problem is, if just a little of light touching the object, the entire object color turned to white ( No Gradation or something like shading )

so my question is

Is there any suggestion or another method to fix that ?

  • 2
    \$\begingroup\$ Wait do you mean "fog of war"? What exactly is the effect you are trying to achieve? perhaps a reference to an existing game for example \$\endgroup\$
    – jhocking
    Aug 11, 2015 at 21:59
  • \$\begingroup\$ How is your world/level constructed? Are you using tiles? \$\endgroup\$
    – Savlon
    Aug 12, 2015 at 0:54
  • \$\begingroup\$ Do you absolutely need to do it using lighting the scene? There are faster, quicker, easier and more "stable" methods (especially if you dont require objects to cast shadows). \$\endgroup\$
    – wondra
    Aug 12, 2015 at 10:45
  • \$\begingroup\$ jhocking i want to create a situation like in the cave, we can't see a thing except using light source, reference game is looks like Amnesia \$\endgroup\$
    – deanrihpee
    Aug 13, 2015 at 3:55
  • \$\begingroup\$ @Savlon no, i didn't use tiles, just normal set of Unity 2D tools \$\endgroup\$
    – deanrihpee
    Aug 13, 2015 at 3:56

1 Answer 1


Maybe i dont understand what you are trying to do, but the standard way to do this is to have a spot light as your flash light. In your case you would disable all lighting sources in the scene and set global ambient lighting to 0. This will make the scene pitch black where only the spot light attached to the player visible.

For 2d you will need to add normals maps to your sprites. this tutorial covers this. https://www.codeandweb.com/blog/2015/05/04/2d-dynamic-lighting-tutorial-for-unity.

With normal mapped sprites your sprites can perform lighting calculations with the regular unity lighting system.

Note you dont need normal maps for sprite lighting, if you angle the spot light correctly you will still light up your sprites. Unity will use the default normal's for lighting calculations.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .