Client - Server Time Synch

edited November 2010 in Photon Server
If in Unity when I want to make sure something will move based on distance-time all I have to do is multiply the distance I want to move each second by Unity's variable Time.deltaTime on every frame update loop
What is the same approach for this in photon?

I know I can use the fiber scheduleInterval for loop calls every few milliseconds that I want.

The Time.deltaTime in Unity is necessary because the game framerate is variable, even if my game will have 60 fps, it isnt 60 fps locked, its always around 60fps. Does that also happen on a normal program, like photon, I never had to deal with this but since every computer program can run smooth or slower (of course there are many factors involved here) I was wondering if that could happen also in a program running. Should I worry about this or just rely on the fiber scheduled interval.

Also, even if photon doesn't have anything like deltaTime, what can I do to keep track of time, lets say I want an Item to have a time to live of 3 seconds, I want to store the actual time the Item was created and start a loop and see if the current time is higher then the creation time + 3. Or, again , should I rely on the fiber interval function, this time I mean the one that gets called only once instead of the lopping interval.

Thanks :)


  • The reason why you need to measure the time on the client is that everything there is done in one infinite game loop. The Fps rate tells you how many loop iterations per second are processed. Fps depends on available resources and the time the calculations require each frame.
    On the photon server there is no single loop - which is good because otherwise photon wouldn't be able to use all CPU cores simultaneously. You can either use the fiber.schedule[oninterval] method, or just a system.timer or any other timer .net offers to schedule your actions. The fiber methods are nice if it's important that the callback is executed on the fiber (actions that run on the same fiber can access the same objects without having to worry about threading issues). Do NOT use loops that do nothing but counting, that would just waste the resources and might block a thread of the .net thread pool - if all thread pool threads are blocked no other work can be performed, which means that no operations can be processed until a thread becomes available again.
  • Thanks for the reply Boris, great to know about the treading, I never thought of that, Imagine if I wanted to wait 10 seconds for a player to respawn and the whole server were waiting on that, it would not be fun =)