- Home /
Draw a flare from inside a solid object.
Is there a way to have a flare show up on your camera if that flare is send from a lightsource inside a gameobject, in my case a sphere.
I've tried setting the culling mask and read docs on lightsources, but I can't find anything on this. I understand this is not the way you're supposed to use flares but it would be a perfect fix for a problem I'm having.
Many thanks in advance!
Edit: Added a bounty because I think the answer might be very relevant to other users as well - even though it's not really important to me anymore atm. Please do only answer if you have an answer, and not just a guess hoping to get the points ;)
Answer by AngryOldMan · Apr 20, 2011 at 08:37 PM
You could parent the object emitting the lens flare to the sphere object at it's forward axis point and then script the sphere it lookAt the player. The lens flare would follow the player round the outside of the sphere, effectively.
Answer by Daniel 18 · Apr 19, 2011 at 07:14 AM
I might have a good enough answer for you. If the object you have the light within has no collider, the flare works. If you needed a collider on that object then I'm not so sure. This suggestion also works with lens flares attached directly to the object. Hope this helps.
Cheers,
Daniel
Incidentally, the flare is visible if you are within the collider area, or if the collider is not obscuring the flare.
Further, setting the geometry to the TransparentFX layer seems to do the trick. Works with colliders and everything. Again, hope this helps. Cheers, $$anonymous$$
Answer by efge · Apr 19, 2011 at 07:21 AM
You could edit the builtin shader (Internal-Flare.shader) and adjust the rendering order with a queue tag and/or play with the ZTest and ZWrite settings. I will make a test and edit this "answer" and add the results.
I also noticed the "collider-effect" (see Daniel's answer) but for me it seems more like a bug?!
I don't think it's a bug. Actually, it makes sense. Terrain and buildings for example, usually have colliders and usually you want flares stopped by these, as sunlight is not passing through either.
Answer by KGC · Nov 17, 2016 at 02:24 PM
You can add the flare component to an empty gameobject rather than a point light. Then you'll have access to a layer mask to control what layers block the flare. See the original answer here: http://answers.unity3d.com/answers/238164/view.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613122202im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Script flares onto lights? 1 Answer
Disabling lights collision 2 Answers
Display Flare from a large object (sun) 0 Answers
How to make Lights for a car? 1 Answer
Light with Flare not working 1 Answer