Search Unity

Assigning Local Authority

Discussion in 'Multiplayer' started by KelsoMRK, Apr 19, 2016.

  1. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    I have a NetworkIdentity that is created at runtime via Spawn() that needs to then be assigned local authority to the "owning player" based on who made the initial request to spawn the object. Assigning localPlayerAuthority to true locally for the owning player and then calling AssignClientAuthority(connection) results in an error message in the console saying "failed to find message handler for message ID 15".

    The connection argument I am using is the one created by StartHost() or StartClient().

    I'm assuming that I need to do this because none of my remote actions are being called on the server when the client calls them locally for these objects.

    What is the correct method for dynamically assigning client authority to objects spawned at runtime?
     
  2. _FLX

    _FLX

    Joined:
    Nov 10, 2015
    Posts:
    85
    There are two ways :
    1) SpawnWithClientAuthority :
    NetworkServer.SpawnWithClientAuthority(gameObject, connectionToClient);
    This spawns an object like NetworkServer.Spawn() but also assigns Client Authority to the specified client.
    http://docs.unity3d.com/ScriptReference/Networking.NetworkServer.SpawnWithClientAuthority.html

    2) AssignClientAuthority (which you tried)
    NetworkIdentity.AssignClientAuthority(connection);
    http://docs.unity3d.com/ScriptReference/Networking.NetworkIdentity.AssignClientAuthority.html


    In the doc example, the connection argument is the client connection.
     
    Last edited: Apr 22, 2016
  3. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Did you read my post? I tried AssignClientAuthority and got an error about not having a handler for message type 15.

    I ended up refactoring and using SpawnWithClientAuthority when no one replied here.