How to make a dynamic fog of war for a 2d maze?

Hey, I’m making a 2d maze game and I have added a mask to make the game a little harder. But the mask lets you look over walls as well. How do I make it so it looks like in the pictures below?

Before:


After:

I’m using a tilemap for the maze layout.

The mask is basically a giant rotating sprite that has a hole in the middle.

Of course it has to be dynamic as well.

Much thanks.

Hello @arjenvklaveren, its not build in, And its a little hard to make one, I suggest you to find an asset that do what you want.
I’ve done one for a little project for school that you can see here: SunStealer - YouTube

A little walkthrough of how i made it:

Raycast some rays in the view angle (number of rays depends of the shadow’s quality you want)

Save the distance in percent of the max view distance (0-1 scaled)

Create a render texture.

Create a compute shader that compare each pixels to the rays value if its outside the ray range so its black.

Use the render texture as cookie for a light.

This method is for sure not the best one ! But it meeted my needs :slight_smile: If you wan’t the package i can give you :slight_smile: But an asset from the store will be better i think :slight_smile:

Hope that will help you,

Raph