The question is answered, right answer was accepted
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!?
Could it have something to do with placing something in front of everything that is affected by the light?
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.
This would definitely work, thank you! I didn't think of this, however I still need to know how to make the scene dark.
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.
Thank you! I want to use the sprite, can you post it?
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!
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
can I have the brush you're using? I tried brushing it over with photoshop, nothing happened.
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.
That would work, however the edges of the circle would be too clearly defined.
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:
Would that make my character visible, though? With the knowledge I currently possess (admittedly close to zero) wouldn't it just cover everything?