- Home /
Question by
GLeBaTi · Nov 09, 2015 at 01:06 PM ·
uinetworkinginstantiate
Server not spawning players model on connected players
Hello. I have this code:
public class NetworkManagerRunner : NetworkManager
{
public Camera serverCamera;
public Vector3 startPosition = new Vector3(0, 3, 0);
public Vector3 startRotation = new Vector3(0, 0, 0);
void Start()
{
if (Helper.IsServer())
{
this.StartServer();
}
else
{
this.StartClient();
}
}
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
{
Quaternion rotation = Quaternion.Euler(startRotation);
GameObject go = (GameObject)Instantiate(this.playerPrefab, startPosition, rotation);
NetworkServer.AddPlayerForConnection(conn, go, playerControllerId);
}
public override void OnServerDisconnect(NetworkConnection conn)
{
base.OnServerDisconnect(conn);
NetWorker.DisconnectUserFromServer();
}
}
Then user connected to server, server create playerModel on server but not on client. Why?
Comment