Search Unity

Resolved How does prediction loop work?

Discussion in 'NetCode for ECS' started by vectorized-runner, Apr 8, 2021.

  1. vectorized-runner

    vectorized-runner

    Joined:
    Jan 22, 2018
    Posts:
    398
    I watched the FPS Sample video and I'm confused about the implementation of the prediction (that runs on the GhostPredictionSystemGroup), as far as I understand

    GhostPredictionSystemGroup.PredictingTick: Starts at Oldest Snapshot Tick and runs until ServerTick as PredictionSystemGroup runs (ServerTick is the Final tick)

    ClientSimulationSystemGroup.ServerTick: Current simulation tick of the Server. This is always synced to the ServerSimulationSystemGroup.ServerTick without requiring to receive a snapshot (I guess this updates with realtime?)

    PredictedGhostComponent.PredictionStartTick: Tick of the latest snapshot applied to the Ghost. No need to update this ghost if this is greater than the PredictingTick

    but then around minute 34 in the video, it shows that client predicts ahead of server tick, but that never seems to happen in my code. Did those things change or is my understanding wrong?
     
  2. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    This is not true, ClientSimulationSystemGroup.ServerTick is always ahead of ServerSimulationSystemGroup.ServerTick. It is always the tick the client thinks the server will have by the time the commands sent this frame arrives on the server.
     
    vectorized-runner likes this.
  3. vectorized-runner

    vectorized-runner

    Joined:
    Jan 22, 2018
    Posts:
    398
    Ok now it makes sense, thanks!