Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

OnStartAuthority is being called on all server objects spawned immediately

Discussion in 'Connected Games' 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:
    221
    @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:
    352
    This seems to be an astounding bug ..... and it's a year later ??