- Home /
Objects is visible in dark... how to prevent that?
NO FORUM QUESTIONS HELPED!
I'm making a 3D game in unity, the only light source is bound to the player. When the platform is not in range of the light I can still see it... How do I fix this?
Basically hide red platform unless the player is near it....
Screenshots:
Relying solely on lighting to prevent a player from seeing an object can be tricky. Depending on your game design, you may be able to just do a distance check between the player and the object and turn the renderer on only when the player is near the object.
I would start by exa$$anonymous$$ing the platform's material. Is it different in anyway, other than color, from your objects that DO get hidden properly? For instance, perhaps you assigned it's material an unlit shader, or used the emission field in the standard-shader.
Answer by AlwaysSunny · Dec 11, 2016 at 11:24 PM
Looks like the scene's ambient light is causing this object to stand out from the surrounding grey objects. You can disable all ambient lighting to prevent this.
Anyone recommend another strategy, since that's probably not what the OP actually wants?
I converted the comment into an answer as this is most likely the only solution.
Things like "black lights"(light that make things "darker") do not exist, neither in computer graphics nor in the real world. The so called black light is actually just ultraviolet light. It's a light spectrum that our human eye can't see. It's simply above the visible spectrum.
In computer graphics by default nothing has light unless you add one. In Unity however the ambient light (which is simply a light value that gets added to the endresult) is set to a dark grey. If you turn it down completely and remove all other light sources from the scene, the whole screen would be pitch black unless you use an unlit material. As long as the material uses the default lighting system it should be completely dark.
I don't see any problems with "relying solely on lighting to prevent a player from seeing an object". Turning the renderer on / off dynamically when the object can always be seen slightly when its renderer is on would just make the object pop-in / out suddenly. This is what you certainly don't want ^^.
Btw: If you can't find the ambient light settings, go to Window -> Lighting. $$anonymous$$ake sure you don't use a skybox. Set the ambient source to "color" and edit the color to be completely black. Also change the "reflection source" to "custom". This should turn everything completely black as long as there is no light.
Here's the result of two default cubes which are on top of each other. I placed a single pointlight in front of the top cube. The "range" sphere slightly "touches" the edge of the bottom cube that's why you see a slight glow below but the rest of the cube can't be seen at all. Note that the cube is actually white.
edit
I just edited the image and copied 4 screen shots next to each other.
$$anonymous$$eep in $$anonymous$$d that you can use layers to make certain lights only affect certain objects. That way you can light the scene as you wish ^^.
Hi, I just wanted to thank you very much for this comment. It helped me tremendously because I was looking through various means to figure out how to make the scene completely dark and I wasn't finding anything. Thus, when I followed your instructions, I was able to get my scene completely dark. Thank you for your comment, I really appreciate it .
Your answer
Follow this Question
Related Questions
Built game colors look way brighter/duller than in the editor 0 Answers
High definition RP And Lightweight Ruined my whole project textures 0 Answers
3d text color 2 Answers
How can i make the game area pitch black 2 Answers
Shader: get nearest point light's color, direction and general custom lighting questions 0 Answers