I am writing a simple multiplayer board game in Unity.
I have the following problem: transport.setparent() not working on a client side. When I launch a game as a server, everything is OK. When I connect to the server as a client transform.setParent() does nothing.
Here is my code:
public GameObject PlayerPrefab;
private GameObject player;
// Use this for initialization
void Start () {
if (!isLocalPlayer)
{
return;
}
Debug.Log("Spawning.");
CmdSpawn();
}
[Command]
void CmdSpawn()
{
player = Instantiate(PlayerPrefab);
NetworkServer.SpawnWithClientAuthority(player, connectionToClient);
player.transform.SetParent(GameObject.Find("BoardPanel").transform, false);
}