I am making a top down shooter, where players have a limited viewing angle. Now I have a dynamic lighting system down pat, however I’ve run into issues with hiding anything that is NOT in your vision cone.
Now the guys at Monaco posted their approach for their sexy lighting and vision, and was wondering how this could be done in Unity?
They mention stencil and stencil buffers, and inverse stencil, but as someone who has never touched shaders before, it quickly goes over my head.
Monaco Game:
What would be the best approach?
Would learning ShaderLab (through the Unity Manual) teach me what is required to pull of something like this?
Any tips, tutorials, or guides are appreciated!
What exactly do you wish to hide from view cone? Only enemies and some objects, or everything and just leave it black?
If it’s just objects, consider implementing a large cone-like collider as a child of your Player object, which is set as Trigger. Anything it touches should fade in the view, and anything not touching it should fade out. You can implement a Hidable interface and extend enemy and object scripts from that, and have the collider cone search for that script in collided game objects.
If you wish to hide everything, you can simply only have one lightsource which is the player, leaving everything else dark. Or if you’ve already lighted up and lightbaked your scenes, consider simply using a screen-wide HUD sprite with cone-like cutout, rotating on the screen mimicking the player’s rotation in the game world.
However as a fellow gamer, I would strongly urge you to re-consider a design decision which makes 80% of my screen useless. Why hide anything not in view cone? Is this really necessary for the mechanics and atmosphere of your game? There have been countless top-down shooters without this mechanic which are working fine. There have also been quite a few with this mechanic that I disliked specifically because of it.