I’m trying to get a script I found on Unify Community to work. It’s a relatively complicated sun cycle routine. Anyway, the sun shines up instead of down for some reason. I’ve been trying to just multiple one of the variables by -1, but it looks like it’s going to be more complicated than that. I’ve emailed the author, but I haven’t heard back, and I was hoping to use it tomorrow. Is there anyone who can troubleshoot this? It would take me a while to digest and fix it my self. Like I said, it works except the sun shines down and around instead up and around, if you follow me. I’ve assigned the timeOfTheDay float to a slider. Thanks.
Honestly, unless you need some supremely complex sun vectors for, basically no reason; use a parabola. If you know where the sun rises/starts, sets/ends, and the apex, you can make a quick quadratic to approximate a symmetric parabolic sun, which works perfectly well for most purposes.
Try changing the last line of setSunPosition from this
transform.LookAt(sunDirection2)
to this:
transform.LookAt(-sunDirection2)
If that doesn’t work, you could make your sun the child of a new empty game object, and on that parent object, change the rotation from 0,0,0 to 180,0,0.
I took a look at the code. From your screen shot it looks like the problem is that you’re setting the Dome Radius to 0. This program calculates a look-at point that is 1 unit radius away form the origin. The Dome Radius is sun’s distance from the origin. So if you set the Dome Radius to anything greater than 1, then it will work as advertised.