Level.TimeSeconds

Discussions about Coding and Scripting
Post Reply
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Level.TimeSeconds

Post by Barbie »

From LevelInfo.uc:

Code: Select all

class LevelInfo extends ZoneInfo native nativereplication;

var           float	TimeSeconds;   // Time in seconds since level began play.
(TimeSeconds does not occur in the replication definition.)
I did not find any update mechanism in the script code but a statement in this thread:
anth wrote:Level.TimeSeconds is updated in ULevel::Tick
So it seems to be updated by the engine, ok. But what kind of seconds - game or real seconds - does it contain? From my tries I've noticed that it contains game seconds, but in above mentioned tread is an opposite statement:
Feralidragon wrote:Level.TimeSeconds is always accurate no matter how slow or fast the game is: 1 second interval is really 1 second.
Second question is about controlling that variable: it seems not to be replicated but managed by the client - it starts always at 0 every time I join the server. Because I want to use "PlayerReplicationInfo.StartTime" (what is set by server to its Level.TimeSeconds) on client, I need to know server's Level.TimeSeconds to calculate the play time. Is there a way to fetch this?
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Chris
Experienced
Posts: 134
Joined: Mon Nov 24, 2014 9:27 am

Re: Level.TimeSeconds

Post by Chris »

Yes it's locally incremented, I guess it starts to count when the new ULevel gets spawned upon connection.

You will want to keep track of it serverside, just capture the TimeSeconds of the server upon player connection. Then when you want to read it all you do is
PlayerTime = Level.TimeSeconds - iCapturedTimeSeconds;
This assumes you subtract it on the server. This also had to be captured for every player and stored in some array by your choice.
Higor
Godlike
Posts: 1866
Joined: Sun Mar 04, 2012 6:47 pm

Re: Level.TimeSeconds

Post by Higor »

TimeSeconds is 'SET' by ULevel::Tick, ULevel class has it's own TimeSeconds in double precision format which is incremented by 'DeltaTime'.
Basically, LevelInfo.TimeSeconds a low precision mirror of ULevel::TimeSeconds.
Changing yields no affect as it simply reflects what's in ULevel::TimeSeconds, and attempting to implement accurate timers using TimeSeconds will cause problems after 30000 seconds or so (floating point precision) so only use it for comparisons bigger than 1.0

TimeSeconds is scaled by game speed so it matches the 'DeltaTime' parameter of Tick.
TimeSeconds starts at 0 in all conditions except standalone/server save game load, in this special case ULevel::TimeSeconds is set to same value as LevelInfo.TimeSeconds during level initialization.
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Level.TimeSeconds

Post by Barbie »

Thanks for bringing light in here. :Light:

Because of my age I'll have forgotten this in 2 months and so I expanded the wiki a bit. Is that wiki description correct, readable and sufficient?
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Level.TimeSeconds

Post by sektor2111 »

A bit false or information lacks, whoever is writing there.
Level.TimeDilation set from game by server at value 1 VS client with initial Level.TimeDilation=5 (edited in Editor) will not be updated (sent to client) because it's a default value - probably a retarded bug again - value being as default class is left alone. Results: Player has a wacky flickering speed - game runs badly screwed because client is trying to stay at 5x speed according to Level setup (brain-farts) and server pull it down constantly at 1x but it won't do any attempt to make a timing. I have forced an update in my games so now I can breath relaxed, both Server and Client are aligned being under a fast check each tick, client is being calibrated if has a deviation from axis. GameSpeed is rewritten so it sends the speed to an actor replicated to client. Each time when speed is changed, actor will be notified. The actor will compare internal value with what Client's Level has. If doesn't match TimeDilation from client, it will be updated.
That Speed-hack probably is not a harder thing to fix but pretty sure I don't have hardware for testing that thing and how to deal with it. Key might be a tracker owned, checking stuff and calibrating whatever values are needed.
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Level.TimeSeconds

Post by Barbie »

sektor2111 wrote:...
Thanks for reply, but it does not address TimeSeconds, does it? Of course TimeSeconds and TimeDilation are both part of the timing system.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Level.TimeSeconds

Post by sektor2111 »

I was tracking that link at Wiki and I've figured questions about right info, etc. No it's not complete, it needs updates...
Post Reply