#Complex Lighting Cycle

1 messages · Page 1 of 1 (latest)

jolly rapids
#

Made with @near swallow's help

Supports different hours for Nighttime and daytime, as well as Synchronization across clients.

jolly rapids
#

Alright that looks nicer

#

Complex Lighting Cycle

jolly rapids
#

lol

near swallow
#

i visualized it like a two part round timer

jolly rapids
#

smart

polar vortex
#

👀

distant torrent
#

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)
jolly rapids
#

the one we made supports having a different length for Daytime vs Nighttime

distant torrent
#

yeah, "it wouldn't have a couple features"

jolly rapids
#

EG, you could have 5 minutes when the sun is out, and 10 minutes when its night

near swallow
#

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...

distant torrent
#

ya, it’s intended to be accurate to the millisecond, if it’s not then Roblox’ll fix it

polar vortex
#

there will be always delay

flint wedge
#

I use the sin wave to adjust how long it should be day and night and to prolong the sunrise and sunsets

jolly rapids
#

yeah but that's a lot more complicated

#

this feels more elegant

jolly rapids
near swallow
#

I kinda get how that would work but I don't see how the sine wave would prolong the sunrise and sunsets

jolly rapids
#

I compared the

#

script activity

#

using GetServerTimeNow

#

to the Delta time method

near swallow
#

any finds?

jolly rapids
#

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

jolly rapids
#

Yeah nvm GetServerTimeNow is slightly better