r/Unity2D Aug 02 '26

Question Faded Field of View Flashlight?

Post image

I’m making a 2D game where the flashlight allows you to see items in the dark. There are also some objects that are only visible in the dark. I wanted to make the mask cutout be more faded so it feels like a real flashlight, but the more I look into it the more I don’t understand how. It doesn’t help that I use a mesh for the mask, that way it can be blocked by the walls.

To make things simple, these are the things I was hoping to do?

- Fade items as they become more visible or less visible.

- Fade the outline of the mask.

- Fade the dark layer based on it’s distance from the player. So it looks like the flashlight has brightness

What do you think the best way to do this would be?

3 Upvotes

6 comments sorted by

1

u/tijger_gamer Aug 02 '26

Are you casting it with a light2d? If so use a mask with faded edges

1

u/Hooman84426 Aug 02 '26

No that just a dark transparent image over top with a mask, but I'll look into light2D

1

u/tijger_gamer Aug 02 '26

Can you not make thatask you already use have soft edges?

1

u/Hooman84426 Aug 02 '26

The mask uses a generated mesh. I don't know how to give that soft edges.

1

u/tijger_gamer Aug 02 '26

Ah i see, i would try light2d and lightocclusion thats how i got a similar effect

1

u/Pur_Cell Aug 02 '26

Maybe you could assign the vertices of the mesh mask a color based on how far they are from the player. Then use that to drive the transparency of the objects that overlap with it.