Skip to content

Commit 9f53619

Browse files
committed
Fixed observer issues
1 parent 348d067 commit 9f53619

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

MLAPI/MonoBehaviours/Core/NetworkingManager.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,11 +1148,13 @@ internal void HandleApproval(uint clientId, bool approved, Vector3 position, Qua
11481148
};
11491149
connectedClients.Add(clientId, client);
11501150
connectedClientsList.Add(client);
1151-
1151+
1152+
NetworkedObject netObject = null;
11521153
if(NetworkConfig.HandleObjectSpawning)
11531154
{
11541155
uint networkId = SpawnManager.GetNetworkObjectId();
11551156
GameObject go = SpawnManager.SpawnPlayerObject(clientId, networkId, position, rotation);
1157+
netObject = go.GetComponent<NetworkedObject>();
11561158
connectedClients[clientId].PlayerObject = go;
11571159
}
11581160

@@ -1177,12 +1179,16 @@ internal void HandleApproval(uint clientId, bool approved, Vector3 position, Qua
11771179
writer.WriteInt(NetworkConfig.NetworkTransport.GetNetworkTimestamp());
11781180

11791181
writer.WriteInt(connectedClients.Count - 1);
1182+
11801183
foreach (KeyValuePair<uint, NetworkedClient> item in connectedClients)
11811184
{
11821185
//Our own ID. Already added as the first one above
11831186
if (item.Key == clientId)
11841187
continue;
11851188
writer.WriteUInt(item.Key); //ClientId
1189+
1190+
if (netObject != null)
1191+
netObject.RebuildObservers(item.Key);
11861192
}
11871193
if (NetworkConfig.HandleObjectSpawning)
11881194
{

MLAPI/NetworkingManagerComponents/Core/InternalMessageHandler.Receive.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ internal static void HandleConnectionApproved(uint clientId, BitReader reader, i
107107

108108
if (isPlayerObject)
109109
{
110-
GameObject go = SpawnManager.SpawnPlayerObject(ownerId, networkId, new Vector3(xPos, yPos, zPos), Quaternion.Euler(xRot, yRot, zRot), reader);
110+
GameObject go = SpawnManager.SpawnPlayerObject(ownerId, networkId, new Vector3(xPos, yPos, zPos), Quaternion.Euler(xRot, yRot, zRot), visible ? reader : null);
111111
go.GetComponent<NetworkedObject>().SetLocalVisibility(visible);
112112
}
113113
else
114114
{
115115
GameObject go = SpawnManager.SpawnPrefabIndexClient(prefabId, networkId, ownerId,
116-
new Vector3(xPos, yPos, zPos), Quaternion.Euler(xRot, yRot, zRot), reader);
116+
new Vector3(xPos, yPos, zPos), Quaternion.Euler(xRot, yRot, zRot), visible ? reader : null);
117117

118118
go.GetComponent<NetworkedObject>().SetLocalVisibility(visible);
119119
go.GetComponent<NetworkedObject>().sceneObject = sceneObject;

0 commit comments

Comments
 (0)