I need some help making the sun move in a straight line across the sky, basically, so the sun just moves in a circle around the sky instead of following the usual path of going across the sky, and then setting, then rising, etc, so like, you take Celestial body dragger, drag the sun, move up into the sky, and spin around in a circle, the little image shows how I want it, being orange the desired path, and red the path I don’t want.
I have a simple idea and understanding on how to do it, but I keep failing to get it just as I want it, if there’s any ideas on how to make the said script or examples, that’d be helpful.
I may have an Idea myself, but I haven’t tested it yet:
You could make a client-sided model with an artificial sun (A big unanchored part with a decal representing the sun), and a PrimaryPart (that’s anchored so there’s no gravity reacting towards it) inside of it, and then create a Weld instance to weld the artificial sun to its PrimaryPart. After that, edit the C0 value of the weld just far enough from the player to make the illusion of the sun.
(Also, set its ModelStreamingMode set to Persistent so it wouldn’t disappear no matter how far it is from the player.)
Then, create a LocalScript and use RunService to set the model’s PrimaryPart CFrame to the player’s HumanoidRootPart’s CFrame.
After that, use a loop to edit the C1 value of the weld to go in the direction you want!
You can also make it replicated in all clients by creating a script in ServerScriptService and a remote in ReplicatedStorage. Then in the script, use a HeartBeat loop to consistently fire the remote with its argument is the set rotation you want the sun to be in.
And then in the localscript, instead of setting the rotation independently, it would accept these events, and set the C1 value of the weld accordingly with the passed argument through the remote.
I do believe this would work, although wouldn’t that affect how Roblox already has light from the sun with the global shadows? I’m making a game that’s very dependent on having light being emitted from a source, and then shadows, it wouldn’t be possible of having any type of point light doing this either, since the scale of everything is extremely large, although I’d have to try this, and see for myself, I’ve also looked into “Real Sun Path” which also creates the same effect I’m looking for, I’m still looking for different options to see what works the best for my needs!
Theres another property which contributes to the Sun/Moon’s position under lighting (I forgot its name but I assure you it exists, I believe its called Longtitude). You can likely work out an equation to find the exact values that property and the TimeOfDay property needs to be to place the sun at a specific position.
You, could use a spotlight instance or something like that for the work-around. But I think you should try BurgerNFries’s idea instead as it would be more optimal. It might be complicated but it would pay-off eventually. Goodluck on developing!
The way Celestial Body Dragger works is by changing ClockTime and GeographicLatitude to move the sun/moon to where the mouse is. This is also how I would do what you’re wanting. I personally don’t know the maths behind it so I’d recommend looking into the code of Celestial Body Dragger plugin.
I tried this, and adding to GeographicLatitude and ClockTime at the same time doesn’t work, since as the sun goes around, it’ll basically eventually meet this point in the middle where the time, etc, just, resets, which does pretty much force it to do the normal path, although form messing around with latitudes and clock time, I did figure out how to have the sun come out at night, and the moon come out at day, which would be useful for moon rays in other projects.
I guess I could try and figure out how to take the code, and make it use like a part as the “cursor” to follow, although I’m not sure, for now, the easiest way to achieve what I want was using the Real Sun Path script, which did exactly what I needed, I just set the latitudes and axle tilt to the Arctic Circle, where the sun is known not to really set for months at a time, and it gave exactly what I needed, although eventually I’d like to script it myself for easier customization, I’ll def keep playing around with the lighting to see what works!
function ToTimeOfDay(n)
local i,f = math.modf(n)
local m = f*60
local mi,mf = math.modf(m)
m = tostring(math.abs(math.floor(m)))
local s = tostring(math.abs(math.floor(mf*60)))
return i..":"..string.rep("0",2-#m)..m..":"..string.rep("0",2-#s)..s
end
function rad_sc(n)
return n/(math.pi*2)
end
function sc_rad(n)
return n*(math.pi*2)
end
function ToLatLon(d)
d = Vector3.new(-d.x,-d.y,d.z) -- derp derp derp derp derp
local lat = math.atan2(d.z,math.sqrt(d.x^2 + d.y^2))
local lon = math.atan2(d.y,d.x)
lat = rad_sc(lat)*360 + 23.5
lon = ToTimeOfDay(rad_sc(lon)*24 - 6)
return lat,lon
end
while true do
for y_t = 0,360 do
local dir = (CFrame.Angles(0,math.rad(y_t),0)*CFrame.Angles(math.rad(20),0,0)).LookVector
local lat,lon = ToLatLon(dir)
game.Lighting.GeographicLatitude = lat
game.Lighting.TimeOfDay = lon
task.wait()
end
end