Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by JackieKan · Dec 23, 2013 at 05:18 PM · field of viewproperty fieldsobject-oriented-programming

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.

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Spinnernicholas · Dec 23, 2013 at 05:47 PM 0
Share

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.

avatar image JackieKan · Dec 23, 2013 at 05:53 PM 0
Share

I don't know how to generate a fog of war

avatar image Spinnernicholas · Dec 23, 2013 at 05:54 PM 0
Share

$$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.

avatar image Spinnernicholas · Dec 23, 2013 at 05:56 PM 0
Share

Fog of war is generated by, either not drawing objects within it, or by drawing a fog over objects within it, or both.

avatar image JackieKan · Dec 23, 2013 at 06:18 PM 0
Share

I still don't understand

Show more comments

4 Replies

· Add your reply
  • Sort: 
avatar image
2

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:

Line of Sight/Field of View on GitHub

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Spinnernicholas · Dec 23, 2013 at 06:34 PM 0
Share

Awesome! I don't know that existed!

avatar image fafase · Dec 23, 2013 at 06:42 PM 0
Share

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.

avatar image
0

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges