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.
  2. Dismiss Notice

Question Client authority for co-op game

Discussion in 'NetCode for ECS' started by Asoprachev, Aug 20, 2023.

  1. Asoprachev

    Asoprachev

    Joined:
    Aug 13, 2017
    Posts:
    9
    Netcode for ECS really amazing tool for dedicated server PC multiplayer shooter, however most unity games are mobile client-host and i want to develop them using DOTS benefits.

    ECS Netcode is not well suited for such tasks, with large pings (~300) I have a huge CPU overhead to client rollback. Most games allows to use fully client authority mode without prediction. But it's like I can't do it in Netcode.

    What do you recommend for client-host co-op games?
     
  2. NikiWalker

    NikiWalker

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    224
    FWIW: We've discussed "partial client authority" internally a few times (as something the user can implement), and the main idea is to send the players client authority state data (like position) as IInputCommandData (a.k.a. input).

    The server just accepts what the client says, and replicates the ghost as normal to other clients.

    It requires some hacking, but you can essentially trust the client for any component data you like. Make the ghost interpolated, then just clobber the interpolation result if you own it.

    We should probably have a sample showing this. Another item for our backlog!
     
  3. Asoprachev

    Asoprachev

    Joined:
    Aug 13, 2017
    Posts:
    9
    Thanks for your reply
    The sample is really important, I think it's worth mentioning in the documentation

    How exactly should I skip apply and interpolation server snapshot on ghost owner?

    I understand that I should to:
    1. create local physics world
    2. setup player ghost prefab to this world index
    3. apply user input in custom physics fixed update (I use velocity for character controller)
    4. inside GhostInputSystemGroup (on client) set to PositionInputCommandData { float3 Position } current Entity Position
    5. inside PredictedSimulationSystemGroup (only for server world) copy from PositionInputCommandData.Position to Entity.Position
    6. Ghost on client automatic synchronize and interpolate (but I should skip it on ghost owner. how?. May be I should create client only cache position component)

    Also about 5, should I use PredictedSimulationSystemGroup for update IInputCommandData, or I can use raw ICommandData?
    And can I force disable prediction rollback system on client?
     
  4. NikiWalker

    NikiWalker

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    224
    Yes exactly, you'll likely need to do this.
    Either or will work, yeah. I only recommended IInputComponentData as it is our newest, most convenient API.
    For a predicted ghost? Likely not very easily, no (AFAIK). "Partial Client Authority" isn't something we've done much work to easily support unfortunately.
     
    Asoprachev likes this.