Syncing Current Position After Reconnection

Hello,

I have a tower defense game and spawning enemies with an interval. enemies have animator on them so moving with animations.

I have 2 problems; first enemies have a sync transform problem like on master client enemy moves from forward but on client they are following with a delay. I tried using transform view and animator view for syncing. But it lagged enemy movement so much.

Other problem is; if i disconnect in a middle of enemy spawn, after the reconnection enemies spawn from starting point again. How can i store current enemy positions and set them to disconnected client?

thanks for help.

Answers

  • a) Lag won't go away. You can try to hide it but this means you predict what is currently happening and need corrections with the state everyone agreed on. In PUN, state is distributed, so it's really hard to agree on everything.

    You may be able to delay the local execution on the Master Client to some degree and hide lag this way.

    Overall, PUN isn't the best tool for such games as it's not tick based and the state is distributed. In Quantum on the other hand, only input is distributed and all client are at the exact same state asap. as the engine is deterministic.

    The downside of Quantum is that you require a Gaming Circle membership at the moment. It is not a free SDK but if you are working towards releasing the game as a product, this is the way to go.

    To stick with PUN 2, I'd try the one package on the Asset Store that is regularly mentioned by our customers and that may help within PUN 2: Smooth Sync.

    b) Copy and modify the TransformView scripts to hide the instantiated prefab until the first "recent" update is received. Then use it as absolute position / state before you begin to lerp between updates. It is sadly not possible to change the position used within the Instantiate event.

  • Hey again,

    I bought asset PUN2: Smooth Sync when you suggested. I am testing multiplayer gameplay with ParrelSync on editor. When i am on Client editor, enemies have a flickering or jittery movement only crossroads (turning left or right), then i am switching to host editor, it is going normal again no jittery, like sth refreshing or reset.

    Is there any lag problems on editor tests on Photon or can it be about send rate or serialization rate?

    I am using dev region to the best pinged one btw.

    Thanks.

  • There is no known issue with the Editor but anything that runs in-Editor will affect your framerate and could produce jitter. This includes but is not limited to Inspector code...

    I would the client to run in a small window to run it twice at the same time. That might make a difference and then you know it's the Editor in some way.

    You could also profile the player code and or the editor but .. that could be a lot of work.