Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

OnStartAuthority is being called on all server objects spawned immediately

Discussion in 'Connected Games' started by EAVN, Mar 4, 2017.

  1. EAVN


    Feb 20, 2017
    Even objects that do not have client authority set. I have several AI objects that spawn immediately upon starting the server or host. None of them should be under the authority of any client, and yet all of them call OnStartAuthority every time the server starts.

    According to the documentation, this method should only be called on a client once the server dictates that it should have authority over a certain object. It should not be called on the server object:

    "When NetworkIdentity.AssignClientAuthority is called on the server, this will be called on the client that owns the object. When an object is spawned with NetworkServer.SpawnWithClientAuthority, this will be called on the client that owns the object."

    Is this a bug, or am I misunderstanding something about how this is supposed to work?
  2. srylain


    Sep 5, 2013
    The server usually has authority over everything, and seeing how a "host" is a client running on the server that gives that client authority over everything as well.
  3. angusmf


    Jan 19, 2015
    @EAVN There is a bug in the HLAPI in NetworkIdentity. In OnStartServer, authority is set to true for all objects that have the localPlayerAuthority flag set to true. That's the little checkbox on NetworkIdentity that you MUST set to true, or otherwise you can never take authority over that object. From what I can tell, ForceAuthority is always called after this, so the authority would be set correctly anyway, so it should be safe to completely comment out the setting of that field in OnStartServer. I think that would prevent OnStartAuthority from running on all objects that have this set. If your objects have the localPlayerAuthority flag set, try turning that off if possible and see if the behavior is the same.
  4. Fattie


    Jul 5, 2012
    This seems to be an astounding bug ..... and it's a year later ??