Search Unity

Netcode - Transfering ghost ownership during runtime

Discussion in 'DOTS NetCode' started by mickee, Sep 1, 2021.

  1. mickee

    mickee

    Joined:
    Dec 26, 2013
    Posts:
    10
    Hi,

    I am synchronizing ghost with Owner Predicted default ghost mode.
    At some point I would like to transfer the ownership to some other player during runtime.

    Is it possible to do so ?

    In the Asteroids example and the documentation, there is no info about whether this is possible or not:
    Code (CSharp):
    1. var e = commandBuffer.Instantiate(nativeThreadIndex, bulletPrefab);
    2. commandBuffer.SetComponent(nativeThreadIndex, e, new GhostOwnerComponent {NetworkId = ghostOwner.NetworkId});
    Can we change the NetworkId after ?

    Thanks for your help,
     
  2. Ali_Bakkal

    Ali_Bakkal

    Joined:
    Jan 26, 2013
    Posts:
    44
    Hello @mickee

    it is a very interesting question.

    Is it possible to change the owner of Network object during runtime ?
    Or have a Network object with multiple owner ?

    Thanks for your help ! @timjohansson @CMarastoni
     
  3. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    386
    Changing the owner is not possible when using owner predicted. Owner predicted means it picks predicted or interpolated mode at spawn time on the client, and the server uses the owner to know if the client is predicting or interpolating the ghost.

    If you change the owner on the client that will just get overwritten with the server state since it is ghosted.
    If you change the owner on the server it will send the new owner to the client, but the client will not switch between predicted / interpolated. The server will assume the client did though, so it will send the wrong data if the ghost has predicted only or interpolated only components.

    There is currently no way to switch between interpolated and predicted mode after spawning, we are investigating ways to make that possible but I do not know when that will be available.
    We have so far not considered using that for changing owner on owner predicted ghosts, but it sounds like it would be useful so I will add a task to our backlog to investigate if that would be possible.
     
    bb8_1, mickee and BenzzzX like this.
unityunity