Require PhotonNetwork.time In Construct3 SDK

Hi ,

I need time sync on every client by using PhotonNetwork.time like in PUN. Is it possible to provide this property in Construct3 SDK too. Or Do you have other solutions?


Thanks

Comments

  • We recently added methods getServerTimeMs() and syncServerTime() for LoadBalancingClient in js SDK but they are not yet exposed in the plugin.

    For now, you can synchronize clients by sending a message to the master client which replies with the current game time. Correct the received value by message roundtrip time. Use this value and the current time to calculate game time.

    PUN and js SDK getServerTimeMs() do basically the same: request server time once, correct it and add the time elapsed since it was received.

  • thanapal
    thanapal
    edited May 2022

    Could you update this function to Construct 3 plugin also?

    It is quite important in my game play.


    Thanks so much.

  • Alexdg
    Alexdg
    edited November 2022

    Hi @vadim I was looking at this thread as I was asking myself similar questions regarding how to sync moving elements, or even physics applied on my players (rigid body) in my game throughout all the clients connected to a room.

    My first idea was to broadcast the time to every clients connected to a room, this time will be defined by the player who created the room. Not sure about that, I guess not ideal as depending on the FPS running on the device, it may not look good (I'm using mobile phones) but it was my first thought.

    Now I can read your answer here, I'm using the JavaScript SDK v4-1-1-4 and I have access to getServerTimeMs() which returns me a negative Ms value, syncServerTime is undefined tho.

    I was wondering if you could give me more details regarding this: "request server time once, correct it and add the time elapsed since it was received."

    Q: What do you mean by correct it? How should I proceed?

    Thank you for your time and help

  • Alexdg
    Alexdg
    edited November 2022

    I read couple of time your last message Vadim and I think I got the idea. I'm doing something like that to get a time consistent on my different devices:

    const rtt = this.client.getRtt()

    const serverTime = this.client.getServerTimeMs()

    const finalTime = ( (timeServer - rtt) * -1 ) / 1000

    with 'this.client' my PhotonLoadbalancing instance

    Also you need to call updateRtt to refresh the Rtt value.