示例#1
0
        static void ApplySpawnPayload(NetworkIdentity identity, Vector3 position, Quaternion rotation, byte[] payload, uint netId)
        {
            if (!identity.gameObject.activeSelf)
            {
                identity.gameObject.SetActive(true);
            }
            identity.transform.position = position;
            identity.transform.rotation = rotation;
            if (payload != null && payload.Length > 0)
            {
                NetworkReader payloadReader = new NetworkReader(payload);
                identity.OnUpdateVars(payloadReader, true);
            }

            identity.SetNetworkInstanceId(netId);
            NetworkIdentity.spawned[netId] = identity;

            // objects spawned as part of initial state are started on a second pass
            if (s_IsSpawnFinished)
            {
                identity.EnableIsClient();
                identity.OnStartClient();
                CheckForOwner(identity);
            }
        }
示例#2
0
 // Called by the server to set the LocalClient's LocalPlayer object during NetworkServer.AddPlayer()
 internal void AddLocalPlayer(NetworkIdentity localPlayer)
 {
     if (LogFilter.Debug)
     {
         Debug.Log("Local client AddLocalPlayer " + localPlayer.gameObject.name + " conn=" + m_Connection.connectionId);
     }
     m_Connection.isReady = true;
     m_Connection.SetPlayerController(localPlayer);
     if (localPlayer != null)
     {
         localPlayer.EnableIsClient();
         NetworkIdentity.spawned[localPlayer.netId] = localPlayer;
         localPlayer.SetConnectionToServer(m_Connection);
     }
     // there is no SystemOwnerMessage for local client. add to ClientScene here instead
     ClientScene.InternalAddPlayer(localPlayer);
 }