NetworkServer.SpawnWithClientAuthority not working?
GameObject Turret = (GameObject)Instantiate(TurretPrefab, tileCastedOn.transform.position + new Vector3(0,0.65f,0), Quaternion.identity);
foreach (GameObject playerGameObject in GameObject.FindGameObjectsWithTag("Player")) {
Player aPlayer = playerGameObject.GetComponent<Player>();
if(aPlayer.team == team){
NetworkServer.SpawnWithClientAuthority (Turret, aPlayer.gameObject);
break;
}
}
Executing the code spawns the Turret only off the host (2 player game), it's executed from a server only object (which has worked for spawning up until this point), the TurretPrefab has a Local Player Authority Network Identity and NetworkServer.Spawn produces the same behavior.
Answer by Vinny-the-true · Nov 30, 2016 at 07:36 AM
No one has any answer on this ? I'm kind in the same situation here, on Unity 5.4.3f1 :
I've got an object for which isLocalPlayer and hasAuthority are both true. First I spawn some Prefab using SpawnWithClientAuthority(), works fine. But then later I try to spawn another prefab, which has "local player authority" checked as well in its Network Identity component, but this one never gets the authority...
This really confuses me...