- Home /
How to make a top down field of view similar to Monaco
I'm working on a 2D top down game, that's supposed to be stealth oriented, but I don't know how to make it so you can't see what's on the other side of walls/corners/etc, similar to Monaco's style, where you can only see whats immediately around you, everything is covered in a sort of fog.
You could setup the scene and then have a fog of war mesh above that. The mesh for the fog of war can be setup to match the scene. That way, you can easily use a vertex shader to set the alpha for entire rooms to 0 to make the room visible.
The hardest part is making the fog of war partially block vision. You would need to find the edge of the object blocking vision and trace a ray out away from the player from the edge. For objects with all flat sides, that will always be one of the corners.
I don't know how they draw those sections of the fog. I might try to generate a fog of war mesh that I can update every frame to do this.
All of these are just ideas.
$$anonymous$$aybe there is a way to do secondary lighting that has infinite power and attach it to the player. $$anonymous$$aybe using layers. It won't actually apply lighting to the meshes. It will affect a custom shader that will make the objects selectively visible. If it's possible, it would be very efficient.
This solution, if possible, is very technically, but very elegant and efficient.
Fog of war is generated by, either not drawing objects within it, or by drawing a fog over objects within it, or both.
Answer by Kellojo · Mar 29, 2018 at 09:42 PM
Even though this is a rather old post, it was the first one I found when searching for a similar mechanic for a project I am currently working on. So I thought I would post the solution I uploaded to GitHub for others to use in the future:
Answer by fafase · Dec 23, 2013 at 06:27 PM
The most simple way is to use a projector light going downward from the camera. Then use a cookie to make the shape. The cookie is that black and white texture that makes the light round, square or else.
http://docs.unity3d.com/Documentation/Components/class-Projector.html
The example above uses the opposite effect you are looking for. The scene is fully lit and the projector is projecting a black halo. You want the opposite, no light in your scene and the projector projecting light so that only what is around is lit.
Good point as well, using a cookie with blurry edges you "kinda" create a gradient that resembles a fog. This is not the real fog of war but the easiest and cheapest way to do so.
Answer by tanoshimi · Dec 23, 2013 at 07:35 PM
This Facebook post explains exactly how they implemented the effect in Monaco: https://m.facebook.com/notes/monaco/line-of-sight-in-a-tile-based-world/411301481995?_rdr
Answer by J0hn4n · Jan 17, 2017 at 10:04 PM
Hey i find this usefull. https://github.com/ncase/nothing-to-hide/
actually MOnaco makes that.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Multi player Game Plugin 1 Answer
2D : Rotation of Object With x-y Axis 2 Answers
Having Problem With Performing Collison with two prefab object. 1 Answer
Distributing Free Games 0 Answers