I am having issues with SpawnWithClientAuthority when "hosting" a match with UNET in UNITY3D. If i create a stand alone server, and connect clients to it, everything works perfectly. If I host a game, where i am also a client, then for what ever reason the hosted client doesn't have authority (hasAuthority is false).
In my game PlayerObject represents my players connection, and TankPlayer is my physical player (the thing i need authority over--to do things like enable its camera).
Here is my spawn code:
[Command]
void CmdSpawnPlayer()
{
GameObject player = Instantiate(m_PlayerTank);
NetworkServer.SpawnWithClientAuthority(player, connectionToClient);
}
This should spawn a tank from my m_PlayerTank prefab (it has "client authority checked). Here are my inspector objects:
Is there a way to make sure the host client has authority in my scripts? Here is where i am checking the authority:
new void Start ()
{
base.Start();
if (hasAuthority)
{
m_Camera.gameObject.tag = "MainCamera";
m_Camera.gameObject.SetActive(true);
Debug.Log("auth");
}
else
{
Debug.Log("No auth?");
}
}