- Home /
When intanstiating an object--it is unaffected by lighting and remains dark. Only ambient lighting works.
Hey all!
So my problem deals with instantiating objects into a scene. If I have the ambient light turned on, all instantiated objects are lit when instantiated. I don't want to use ambient lighting however.
I'm doing a 2d game and using a directional light to emulate the ambient light--but setting it to specific layers so each background layer can be lit darker than the foreground.
So I'm instantiating bullets that are set to their own layer with a directional light that is set to the same layer yet they aren't lit by the light. If I set another object that isn't instantiated to that same layer--it is lit by the light when the game starts rendering.
The only solution I've found--which doesn't work actually--is instantiating a light with the instantiated bullet--it works sometimes--and half the time the bullets still aren't lit or turn off halfway through their lifetime.
So is this a bug in Unity?
The only answer I've figured out is to instantiate all the needed bullets with the scene and rotate them out of an array rather than instantiate/destroy. This is all good and well and I need to do this anyway for performance reasons--but this is still a problem--especially when I'm going to start instantiating levels procedurally. Has no one experienced this issue before?
Update: I tried upping the # of pixel lights in the quality settings--living on a prayer--it also did not work.
Answer by robcbryant · Mar 17, 2014 at 07:25 AM
Finally!! 2 weeks of dealing with this and I figured it out.
The directional light set to the culling layer that should always be lit(The layer with instantiated bullet objects) needed the "Render Mode" changed from "auto" to "Not Important". I'm not sure why this is the case--but it works regardless. If someone wants to explain this to me please do!! I hope this helps anyone else with this problem.
Your answer
Follow this Question
Related Questions
Lightmap details 0 Answers
How do I fix my lightmap problem? 2 Answers
is there any advanced lighting tutorial 0 Answers