• 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 /
  • Help Room /
This question was closed Nov 29, 2016 at 11:20 PM by Nova-1504 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Nova-1504 · Nov 21, 2016 at 03:47 PM · 2dspriteshalonightdarkness

How to make a 2d game dark

I am making a 2d game where I want it to be completely dark except for where the player is. I added a Halo effect to the player and then had no clue what to do for the darkness. I don't want the sprites to be visible unitl the halo reaches them. How do I do this? PLEASE!?

Comment
Add comment · Show 3
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 Nova-1504 · Nov 21, 2016 at 04:09 PM 0
Share

Could it have something to do with placing something in front of everything that is affected by the light?

avatar image Nova-1504 · Nov 21, 2016 at 06:40 PM 0
Share

Would this work? LIN$$anonymous$$

avatar image Nova-1504 · Nov 22, 2016 at 10:35 PM 0
Share

Somebody please answer!?

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by TheShadyColombian · Nov 24, 2016 at 09:34 PM

If it's not a pixel art game where you can have perfect circles, use a spot light. Since it's 2D, just have it pointing down the Z axis. If you'd like, you can also add a Cookie texture to add noise or a special shape to the light.

In case it IS a pixel art game, you could still do the above, except you'd need an advanced shader of sorts to make the light create a pixelated area. I don't go near shaders so I'm not even all that sure it's possible.

Let me know if you need more help, or a more in-depth explanation.

ps. some quick tips about Unity Answers from a 2+ year user: 1) If you want to make things more clear, edit your question, don't add a comment to it. 2) Don't be desperate. If someone knows the answer, they would have posted it already. Saying "please help" won't make people magically know the answer to your question. 3) include as much info in your question. In this case, visual style of the game would be helpful to know what types of things work or don't work. These tips will make it easier for you to get help in Unity Answers.

Comment
Add comment · Show 13 · 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 Nova-1504 · Nov 24, 2016 at 11:11 PM 0
Share

This would definitely work, thank you! I didn't think of this, however I still need to know how to make the scene dark.

avatar image Nova-1504 · Nov 25, 2016 at 10:38 PM 0
Share

See the link on one of my original comments

avatar image TheShadyColombian Nova-1504 · Nov 26, 2016 at 04:39 AM 1
Share

You COULD do that, but I$$anonymous$$O it's a lot more complicated than it needs to be for a simple 2D sprite-based game. Simply use the image i posted as a brush on a black image, and basically make it all black, but transparent on that section. Stick it on top of your player, and you're good to go. I can create the modified sprite if you'd like.

avatar image Nova-1504 TheShadyColombian · Nov 29, 2016 at 01:53 PM 0
Share

Thank you! I want to use the sprite, can you post it?

Show more comments
avatar image tokenacc001 · Nov 02, 2018 at 01:48 AM 0
Share

hello @TheShadyColombian , sorry for reviving this but, I just tried using the sprite you made and added a Sprites/Diffuse material on it then a spotlight on the scene, and I was wondering why it has a black circle in the middle? thanks in advance!

https://imgur.com/2ey1E0e

avatar image TheShadyColombian tokenacc001 · Nov 07, 2018 at 03:23 PM 0
Share

No worries. Shouldn't be there, it's probably just a compression artefact. If it bugs you or is causing you issues in your game you can easily brush over it in Photoshop or Gimp

avatar image tokenacc001 TheShadyColombian · Nov 09, 2018 at 11:09 AM 0
Share

can I have the brush you're using? I tried brushing it over with photoshop, nothing happened.

Show more comments
avatar image
1

Answer by mycahkrason · Nov 23, 2016 at 01:35 AM

Hey, I'm not exactly sure what you want specifically, but couldn't you just make an image in photoshop or gimp with a hole the size you want for your halo, and then just attach that to the player so it moves along with them? and if the image is large enough to cover the whole screen, then the sprites will only be visible when they are within the hole in black image. That may not be the best way to do it, but that's the first idea i had.

Comment
Add comment · Show 3 · 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 Nova-1504 · Nov 23, 2016 at 08:42 PM 0
Share

That would work, however the edges of the circle would be too clearly defined.

avatar image TheShadyColombian Nova-1504 · Nov 24, 2016 at 09:47 PM 0
Share

I think @mycahkrason meant a circle with a gradient fill, like such. I made it myself, so let me know if you plan to use it, if it suits your needs:

http://imgur.com/a/WrxDP

avatar image Nova-1504 · Nov 24, 2016 at 11:26 PM 0
Share

Would that make my character visible, though? With the knowledge I currently possess (admittedly close to zero) wouldn't it just cover everything?

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

Unity 2d - Coordinate grid is way to big? 1 Answer

Unity 2D Sprite artifact/bug 1 Answer

Sprites showing through each other in 3D 0 Answers

How do I render Particlesystems in front of 2D sprites? 2 Answers

The spacing between sprites are inconsistent 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