- Home /
How to make an always visible spotlight?
Hi!
I have a problem with my game: I'm trying to use a spotlight on top of my unit that will send a light circle on the terrain when I select the unit, the problem is that when the unit go away from the camera the light disappears. Is there a way to make a spotlight always visible, also at great distance?
Thanks!
P.S. I add a link to my work so you can evaluate the problem (hope that this doesn't brake any rules..)
http://federicolaggiard.altervista.org/forumExample/WebPlayer.html
you can click on the unit an then on a far point on the terrain, the result was that when the soldier go too far the red circle upon it will disappear.
With "unit" I mean the mesh that I use to represent a soldier...maybe a link to see my work can help?
Answer by ZioFede87 · Nov 11, 2011 at 11:43 AM
I've solved this issue using a plane with a texture applied on it.
I've tried with a decal projector, as suggested by Fabkins, but this doesn't solve the problem of the disappearing light on long distance. So a simple mesh do the work for me.
Thanks all for your replies.
Answer by Rookhaven · Nov 08, 2011 at 08:33 PM
If you want your unit to always be lighted, you could make the light a child of the unit and it will move with him (rotation and all).
Another option is if you don't want your spotlight to move, but always be visible, you don't really need the light unless you want the ground lighted. You would need a texture with an alpha gradient that looks like light shining in the appropriate direction (sprite). Then attach the texture to a material with a transparent shader to see through it. If you want the gound lighted, parent the light to the sprite or vice versa. Make sure the sprite doesn't cast or receive shadows though.
Thanks for the answer!
I've used the spotlight because it make more simple (for me) to project the circle on a rising surface (ex. a hill), probably that's not the correct way, maybe you can point me on a tutorial that explains how to use a sprite in that way?
I've added a link to my demo so you can see the problem
Answer by Fabkins · Nov 08, 2011 at 08:36 PM
You could make the light Render Mode: "Important" in the inspector for the light.
Also is the light attached to your "unit"?
Thanks for the answer!
I've try to make the light "important" but that not solve the problem. Yes the light is attached to the "unit" (it is wrong call it that way?? sorry for my bad English..) so they will move togheter.
Ok. I would create a light. Attach it to the player (make sure position slightly above him, like 0,2,0):
Type: "Point Light"
Range: 10
Color: White
Intensity: 1
Shadow type: no shadows
Render mode: important
Culling $$anonymous$$ask: Everything
Lightmapping: Realtime Only
If that doesnt give you a light I'm puzzled.
Also stick an object near by to see if that lights up although I cant think of what you could have done to the terrain.
Sorry, but I don't understand. Did you have see the demo in the link up there? I already have a light with the following characteristic:
Type: Spot
Range: 10
Spot angle: 20
Color: red
Intensity: 8
Cookie: (I've created a personalized cookie)
Shadow Type: no Shadow
Draw Halo: no
Flare: none
Render mode: important
Culling mask: terrain
Lightmapping: auto
I've also attached a script that allows me to activate/deactivate the light and make it rotate
Still the light disappear when the soldier go too far from the camera.
Thanks again for ur help
Ah , I couldnt figure out how to move your player and didnt see the light at all. Now I see what you are doing.
Looks like you got issues with the far clip plane as a guess.
For what you are trying to do a light isnt the right thing as ZioFede said. Use a decal or maybe even a projector.
Your answer
Follow this Question
Related Questions
Low shadow quality from distance light 2 Answers
iPhone: what's the best way to create disco-type spotlights? 0 Answers
Light Cookie problem 1 Answer
Light and lag problem 0 Answers
Poor spotlight gradient in Unity 1 Answer