- Home /
How do I make a wall block light in 2D?
I have a 2D Puzzle Platformer that I am working on that has ambient lighting (One of the mechanics revolves around lighting). I am currently having a problem where light will go through walls, like so: Is there any way, short of creating a new shader, to prevent this from happening?
EDIT: Just as clarification I am using Sprite Renderers on everything you see and the Sprites/Diffuse Shader.
It's not possible. The only thing you can do is to put a 3d wall between the light and the sprites.
Is that a viable solution? I wouldn't be opposed to it if it doesn't create other problems.
It is fine if you don't have colliders on it.
Its not directly available, however, if you check out something like Sprite Lamp you can do it.
Sprite Lamp uses a bump map and a normal map to help give the illusion of depth on a 2D surface. I'm not saying you have to use the software, but if you check it out i'm sure you'll get the general gist of how it works and can manually reproduce the bump maps and normal maps yourself. I haven't played with it myself, but i know that method works with Unity.
Personally I have played around with AutoTileGen, which does the same thing as Sprite Lamp and I have tested it and confirmed that it does in fact work in Unity. From your image above, I actually think it may be more along the lines of what you need.
I should note that the version of AutoTileGen on S$$anonymous$$m is better than the one that I linked to above.
Do these two assets/solutions adress the actual problem at hand, which is having sprites not blocking light?
Answer by qiqette · Mar 06, 2016 at 08:16 PM
Search for dynamic lighting and shadows 2d in the asset store, there a few assets for free
Not that work with Unity's lights, AFAI$$anonymous$$. They work by simple raycasts to deter$$anonymous$$e areas that are occluded from a given point.
Your answer
Follow this Question
Related Questions
Torchlight effect in 2D 3 Answers
Directional light 2D 0 Answers
Prevent light combining with other lights 0 Answers