#Complex Lighting Cycle
1 messages · Page 1 of 1 (latest)
im still baffled at how you figured out the solution so quick
lol
i visualized it like a two part round timer
smart
👀
You could've also done this granted it wouldn't have a couple features but it'll still be synchronized across clients (unless I missed something)
local Lighting = game:GetService('Lighting');
local RunService = game:GetService('RunService');
local serverTime = game:GetServerTimeNow();
local serverDelta = serverTime - os.clock();
local cycleDuration = 300; -- in seconds
local hoursPerSecond = 24 / cycleDuration;
RunService.Heartbeat:Connect(function()
local deltaTime = os.clock() + serverDelta;
local clockTime = (deltaTime * hoursPerSecond) % 24;
Lighting.ClockTime = clockTime;
end)
No this is different
the one we made supports having a different length for Daytime vs Nighttime
yeah, "it wouldn't have a couple features"
EG, you could have 5 minutes when the sun is out, and 10 minutes when its night
so I'm assuming the most elegant implementation then would be to just use GetServerTimeNow instead of having a remote handler on the server side
makes sense...
ya, it’s intended to be accurate to the millisecond, if it’s not then Roblox’ll fix it
I would say it's 99.9% sync
there will be always delay
I use the sin wave to adjust how long it should be day and night and to prolong the sunrise and sunsets
How would you go about this implementation
I kinda get how that would work but I don't see how the sine wave would prolong the sunrise and sunsets
@near swallow I was just working on an addition to this, and tried out implementing this
I compared the
script activity
using GetServerTimeNow
to the Delta time method
any finds?
and GetServerTimeNow maxed out at 2% script activity, whereas DeltaTime maxed out at 0.7%
that's 0.7% with invoking each day cycle btw.
wait hold on
one second
one second
Yeah nvm GetServerTimeNow is slightly better