Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. 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. crynryan

    crynryan

    Joined:
    Sep 5, 2013
    Posts:
    158
    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:
    192
    @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:
    311
    This seems to be an astounding bug ..... and it's a year later ??