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);
}
}