Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Resolved Netcode and Interpolated Synchronized Component on a Predicted Entity

Discussion in 'DOTS Dev Blitz Day 2022 - Q&A' started by Kmsxkuse, Dec 7, 2022.

  1. Kmsxkuse


    Feb 15, 2019
    Am I correct in assuming that if I put a synchronized ghost component on a predicted entity, like the local player, and only read from it, the values within that ghost component will be the interpolated values from the server?

    Basically the predicted player entity will have a ghost component with a float value. That float value will only be written on the server and read on the client. Will the results of that float using the parameters Clamp and not InterpolateAndExtrapolate be values that are most recently received from the server?
  2. CMarastoni


    Unity Technologies

    Mar 18, 2020
    No. predicted ghost does not interpolate ghost fields. They are updated as part of the prediction loop and all the replicated component are usually updated there. The value is just and always Clamped to the last received form the server.
    The Interpolate and InterpolateExtrapolate only apply for interpolated ghosts.
    Kmsxkuse likes this.
  3. NikiWalker


    Unity Technologies

    May 18, 2021
    It depends. Your ghost is predicted, so it'll run all prediction code on the client. If you have prediction code that writes to your custom ghost component, your client is predicting those values.

    You'd only achieve your desired behaviour if the code that writes to the component is entirely outside the prediciton loop. But note: Ensure your prediction code doesn't read it, otherwise your client will be constantly miss-predicting.

    Yeah, Clamp ensures that the value will jump straight to the latest value, when a snapshot is received.
    Note though: When predicting an entity, `SmoothingAction.Clamp` is forced. `Interpolate` and `InterpolateAndExtrapolate` are only useful with Interpolated Ghosts.
    Kmsxkuse likes this.