Hi, I am extremely new to Unity and I am following a course on how to make a basic 2D RPG game.
I was wondering if anyone had any suggestions on how to darken the screen a certain distance away from the player, so that when the player is zoomed out, you can’t see any other parts of the dungeon.
Thanks!
This is generally known as the fog of war which is an actual military term. Different games have quite different implementations of it. A lot of games have adopted a two stage system. Completely dark for a completely unknown area. Light grey for areas you have already revealed but essentially contains “outdated” information. Most games with a two stage system simply do not render dynamic elements like enemies outside of the actual view range but keep the static terrain information.
Implementing such a system generally involves several seperate things. One aspect is the visual representation, the other the logical representation. There should be countless of exampels on the internet when you seach for fog of war. We can’t explain how one may implement such a system in all details here. Especially since there are too many variations how such a system may be implemented. Though using an overlay texture for the static geometry that is updated as you reveal new areas is quite common. Writing shaders that can handle several primitive shapes (usually circles) to represent the dynamic area is also quite common.
Though the first thing you should do is decide and sepcify what exact behaviour you want. If you’re uncertain, do some research by looking at other games to see what they have done.
There are ready-to-use solutions out there. The asset store contains some paid solutions as well. So if you don’t have the time or the will to learn how to implement something like that yourself, you can simply buy such a solution.