- Home /
How do I make light not pass through 2D wall sprites?
I'm working on a top down prototype where a character with a flashlight walks around. The flashlight is a Spotlight that's attached to the player. I did something similar in 3D, with cubes, but I want to make a 2D sprite game, due to art constraints.
Note: I've already made a diffuse sprite material, so that the light interacts with sprites.
I think if you are using Unity Pro, then the Cast and Receive Shadows options in renderer doesn't let the light pass through.
If you are not using Unity Pro, then I don't think that can be solved. But I am not sure really.
Answer by Headworker · Feb 25, 2014 at 08:48 AM
I have been researching this for quite some time.
The only (and really awesome) way to solve this (I currently know ) is using this (paid) asset: 2D Volumetric Lights
This does not only give you the required functionality and some really awesome visuals (I am not getting paid for this advertising, its just a really powerful and easy to use tool :) )
For example, you could try to check if something is within the lightcone of a specific player, to switch rendering on/off for instance (basically gives you the effect that the player can only see things inside the cone of his flashlight). The asset has a plug-and-play function for that, takes about 3 lines to get it set up.
There is (probably) another solution, but this is in my opinion the fastest, easiest and most beneficial way.