How to make a new type of light in unity

I wondering if we can make a new type of light in unity.

I am trying making a scanner light for my enemy, but if I use a plane or a cube with particles/additive shader on it, although it looks good but it still go through walls.

I had tried with depth mask in unity,but it can not solve the problem that when some gameobject go through my “light” shape, it still have the part behind it.



You don’t want to use a light for this - there are all sorts of problems involved with that method. What you want is a script that can deform a mesh based on raycasts. It’s pretty easy to do for a simple shape, just raycast out along the direction of the shape, and then shift the vertex position of the far end of the mesh to match the collision point (or reset it if no collision was found). This will be quite expensive, depending on the complexity of your mesh, but it should be quite workable.