- Home /
How can I make a sun, complete with animation and lens flares?
In the real world, the sun always moves around the sky. To simulate that, is there a way to move the lens flare through script or other ways? I noticed that moving the direction light does not change where the flare is draw.
Can i emulate a sun like object by moving the Flare and changing the angle and intensity of the light?
I would appreciate it if any code is in JavaScript :)
Answer by Statement · Dec 16, 2010 at 02:25 PM
To simulate that, is there a way to move the lens flare through script or other ways? I noticed that moving the direction light does not change where the flare is draw.
If you place a lens flare on the same object as your directional light, and set the lens flare to be directional, then it'll work just fine. No code required.
If your lens flare object and your light object are not the same, you can glue them to point in the same direction with a script that require you to bind the directional light to the script, and this script should then be on the lens flare (but the above approach probably is more elegant to use)
// Before using this script, review the first offered solution. var directionalLight : Light;
function Update() { transform.forward = directionalLight.transform.forward;
}
- Simple gotcha: Remember that you should rotate the directional light (and directional lens flare) instead of moving them by translation, as that information is ignored.
Ok, now I understand that the position is irrelevant to lighting but rotation matter :D.thanks!
Answer by GGS · Jan 07, 2011 at 10:16 PM
burgzergarcade.com has a series of video tutorials that detail day/night simulation, and although thorough enough to be easily replicated (the code is provided) it is done in C#.
Your answer
Follow this Question
Related Questions
Making A Particle Play when KeyPress And Particle Stop in 3 sec. 1 Answer
Create random forces to simulate dice 1 Answer
Adding lens flare to sun 0 Answers
Lens-Flare Muzzleflash 0 Answers
Setting Scroll View Width GUILayout 1 Answer