Search Unity

Synchronization between network tick and physics simulation for client side prediction

Discussion in 'Netcode for GameObjects' started by Shadow55AA, Oct 26, 2022.

  1. Shadow55AA

    Shadow55AA

    Joined:
    Oct 25, 2018
    Posts:
    1
    I've nearly successfully implemented client side prediction with netcode for game objects 1.0.0 and unity 2021.3.11f1. Since the only dynamic rigid body is the player, I'm using physics.simulate to reconcile a misprediction(disabling and enabling autosimulate before and after). But after some tinkering, using a simple server only counter, I've counted more than 1 FixedUpdate function call between NetworkManger.NetworkTickSystem.Tick function calls. As noted in the documentation for NetworkTime and Ticks, I have network tick rate at 50 and Fixed Timestep at 0.02. I'm using autosimulate on the server. It does not appear that the Network.Tick function and autosimulated physics is running in perfect synch, so I figured I could switch to manual Physics.Simulate for all simulation to be certain the number of physics steps performed between network ticks is exact and consistent. I require fixed timesteps to ensure deterministic behavior(or as close as I can get), but I can't seem to figure out how to ensure physics.simulate is run in between calls to Network.Tick for all objects. Is there, currently, any means doing so? If so, please enlighten me.
     
    CodeSmile likes this.
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,942
    Would like to know that too.
    Btw, you are aware that client side prediction is on the roadmap, either as planned or even in progress, can‘t remember.

    Since NGO is open source it can‘t hurt to dig into the repository, might actually be easy to add your own PreTick/PostTick events.
     
    Shadow55AA likes this.