• Question about CurTime().
    6 replies, posted
What is the difference between CurTime() and UnPredictedCurTime() (timers use this)? Is CurTime() synced on the client? If the server hangs for 5 seconds, then resumes is the client's CurTime() resynced? [b]Question answered[/b]
Considering CurTime is from the server start, it's probaly synced once when joining. And i guess it should sync just in case the client gets out of sync... (makes sense). But i'll hand this over to someone better at this :)
I doubt that CurTime is synced, but if it is, UnPredictedCurTime would be the unsynced one.
[QUOTE=DarKSunrise;18730866]I doubt that CurTime is synced, but if it is, UnPredictedCurTime would be the unsynced one.[/QUOTE] It [i]is[/i] synced.
CurTime is both predicted and synced. A CurTime() is associated with each Tick frame - this tells the client the game time at that tick, and between ticks on the client CurTime() is predicted. In other words this means the client does the same thing as the server to CurTime(), but the server occasionally corrects the client. When this happens the expected CurTime() may jump forwards or even backwards which is particularly problematic for things that expect CurTime() to do nothing but keep going forward - particularly UI animation, which may stutter. For UI, use RealTime(). For anything else that is completely clientside taking place in the game world (such as effects), use UnpredictedCurTime(). NOTE: The speed that CurTime() and UnPredictedCurTime() increase by each frame is determined in part by host_timescale. However, RealTime() is not affected by host_timescale (which may or may not be a good thing depending on what you're making).
That is one of the most informative responses i have seen. Should be added to the wiki
[QUOTE=theJ89;18731203]CurTime is both predicted and synced. A CurTime() is associated with each Tick frame - this tells the client the game time at that tick, and between ticks on the client CurTime() is predicted. In other words this means the client does the same thing as the server to CurTime(), but the server occasionally corrects the client. When this happens the expected CurTime() may jump forwards or even backwards which is particularly problematic for things that expect CurTime() to do nothing but keep going forward - particularly UI animation, which may stutter. For UI, use RealTime(). For anything else that is completely clientside taking place in the game world (such as effects), use UnpredictedCurTime(). NOTE: The speed that CurTime() and UnPredictedCurTime() increase by each frame is determined in part by host_timescale. However, RealTime() is not affected by host_timescale (which may or may not be a good thing depending on what you're making).[/QUOTE] This helps a crapload, thank you very much.
Sorry, you need to Log In to post a reply to this thread.