I would like “sunlight” to be emitted from this part. However, as we know, Roblox limits lights to 60 studs, therefore placing a light object inside the part wouldn’t even surpass the sun’s radius (1400 studs).
I’ve tried a few methods. First I’ve used the same math used in CloneTrooper’s in Celestial Body Dragger to match the skybox sun (which is hidden) with the player’s position.
local dir = (sunPos - hrp.Position).Unit
local lat = atan2(dir.Z, sqrt(dir.X ^ 2 + dir.Y ^ 2))
local lon = atan2(dir.Y * lf, dir.X * lf)
local geoLat = (lat / tau) * 360 + 23.5
local ct = (lon / tau) * 24 - 6
lighting.GeographicLatitude = geoLat
lighting.ClockTime = ct % 24
Works beautifully well for a certain range of positions however when you go past that, the clocktime dips below the noon phase, which roblox assumes as “night” and the skybox sun stops emitting light. Another problem is that if I want to use sunrays they will yellow out to indicate evening as the clocktime reaches 17:00 when the player is at certain positions.
With that out of the way, my only option is to use LightObjects and change their position to match that of the player. This is how I tried positioning an attachment under which a SpotLight object with max settings resides.
local sub = (sunPos - hrp.Position)
local attPos = sunPos:Lerp((hrp.Position - cp.Value.Position), (sub.Magnitude - 50) / sub.Magnitude)
att.WorldCFrame = CFrame.new(attPos, hrp.Position)
It works nice, but doesnt look good because the rest of the sunfacing side of the planet isnt illuminated properly…
Doesn’t surface light cover the entire surface of the part? using this, you could have one surface light, at the end of that make a part the size of the range of all that and place it at the end, put another surface light, ect. you could put these in a model and just move it, using the original part as PrimaryPart. Edit: nvm, didn’t see the 1.4k studs part. This would be extremely laggy.
Well yes I did try that but surface lights emit light from one face. Problem is that when the player moves to the other side of the planet (the dark one, away from the sun) the part containing surface light enters into the planet and create a stripe of light across the planet which doesnt look nice.
Why not CFrame a SurfaceLight Cylinder Part (let’s say it’s 2000 studs diameter) always just over half it’s width away from the surface of the planet, but between the ‘sun’ and the player.
That way you could have my example Part be 1005 studs above the surface of the planet, but facing 90 degrees to the surface when it’s at the point between day and night so it doesn’t create the stripe.
Then if the SurfaceLight Part is past the CFrame Position of the Planet from the Sun you can just code it so it isn’t rendered, moved, or enabled to turn it off so it doesn’t llluminate the dark side.
I mean yeah its possible I didn’t think about having a cylindrical part, and I did use an attachment in the first picture placed between the sun and the player.
light wont reach the surface from 1005 studs, if thats what you meant.
Honestly yeah, I feel like thats the only way to get something done.
Yeah, the dimensions were just an example.
If you used a 110 stud diameter SurfaceLight Part, mounted 55 studs away from the surface, but aligned to the ‘sun’ using a CFramed ‘lookAt’ and moved toward the sun by say 55 studs it may work.
Maybe not. I just thought of diagonal issues with the Part at 45° to the planet surface which would create a bright spot at the closest edge of the Part…