Increase precision of Lighting time to retain sub-second values

With Lighting:SetMinutesAfterMidnight(), the time passed in gets floored to the second internally when the actual time is being set, which is not enough precision. The precision should be updated so that the service can ingest any value for SetMinutesAfterMidnight and also return that same value again upon using GetMinutesAfterMidnight.

An example of current problematic behavior is:

game.Lighting:SetMinutesAfterMidnight(2.323498293489324)  
print(game.Lighting:GetMinutesAfterMidnight()*60)
--> 139 (rather than 139.4098...)
-- i.e. does not maintain the decimal part that cannot be represented in seconds

Day and night time cycles are a common feature in Roblox games, where the sun and moon rise and set. For the sun and moon to move smoothly, the time of day needs to be updated frequently.

As an example, developers may want to set one second in real life to correspond to a minute in game, and update the time at 60 hz. If they are unaware of the loss of sub-second precision, they would be roughly 20 minutes off in game time per minute of real time.

Developer mitigation currently requires a carryover value to be stored and updated every update, and this behavior is not documented on the Developer Hub.

4 Likes