Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

OnStartAuthority is being called on all server objects spawned immediately

Discussion in 'Multiplayer' started by EAVN, Mar 4, 2017.

  1. EAVN

    EAVN

    Joined:
    Feb 20, 2017
    Posts:
    3
    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

    srylain

    Joined:
    Sep 5, 2013
    Posts:
    159
    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

    angusmf

    Joined:
    Jan 19, 2015
    Posts:
    261
    @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

    Fattie

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