public override void OnServerAddPlayer() Issue

I’m using a custom network manager class, and for now I’m simply trying to successfully override the OnServerAddPlayer function. The issue I’m running into is that the player isn’t being given authority over the GameObject. If in a script attached to the player’s GameObject I run a Debug.Log about the NetworkIdentity.isLocalPlayer … it returns false for the client (and the host for that matter). My custom network manager class is below.

using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Networking.Match;

public class Network_Manager : NetworkManager
{

    public override void OnServerAddPlayer(NetworkConnection _connection, short _playerControllerId)
    {
        GameObject obj;
        Vector3 pos = Vector3.zero; //CODE WILL GO HERE TO GET PLAYER'S LAST STORED VECTOR 3 FROM A DATABASE.
        Quaternion rot = Quaternion.identity;

        if(_playerControllerId > 0)
            obj = Resources.Load("Prefabs/Sphere") as GameObject; //TEMPORARILY USING A CUBE AS A PLAYER'S MINION FOR TESTING.
        else
            obj = Resources.Load("Prefabs/Cube") as GameObject; //TEMPORARILY USING A CUBE AS THE PLAYER FOR TESTING.

        Instantiate(obj, pos, rot);

        NetworkServer.AddPlayerForConnection(_connection, obj, _playerControllerId);

        if(_playerControllerId > 0)
//IF THIS IS A MINION THEN WE NEED TO LET THE CLIENT'S PLAYER GameObject BE ASSOCIATED WITH IT.
            _connection.playerControllers[0].gameObject.GetComponent<Test_Input>().Activate(obj.GetComponent<NetworkIdentity>().netId, _connection.connectionId);
    }

}

BUMP … nobody willing to help me look into this?

Just from this snippet, I don’t see anything that looks incorrect. Is the player unable to control their player object at all? Where is your Debug.Log that says NetworkIdentity.isLocalPlayer is false? I think on the server, that will be true by the time Start() is run, but on the clients I believe that doesn’t become true until at least StartClient is run (I’m assuming Test_Input is a NetworkBehaviour?). Also, make sure that you’re registering those prefabs you’re grabbing with Resources.Load before you instantiate them. They need to be registered on both the clients and server.

Did you set LocalPlayerAuthority on the NetworkIdentity of your player/minion prefabs?

Correct. They are unable to perform anything authorative on their object.

I have it in the Update() function.

I’ve also tried it this way…

obj = singleton.playerPrefab as GameObject;

…on line 17. Still doesn’t work.

Yes.

Yes, “Local Player Authority” is checked on the prefab. The issue isn’t with this variable of the NetworkIdentity…it’s with the “isLocalPlayer” variable. It’s not being set to true.

Replace line 19 with:
val thing = Instantiate(obj, pos, rot);
Then add:
NetworkServer.Spawn(thing);