Properly reset scene gameobjects when we receive OnObjectSpawnScene

This commit is contained in:
Paul Pacheco 2018-06-28 19:05:20 -05:00
parent ec7185ad49
commit 78d159d7da

View File

@ -415,6 +415,7 @@ static void OnObjectSpawn(NetworkMessage netMsg)
if (s_NetworkScene.GetNetworkIdentity(msg.netId, out localNetworkIdentity)) if (s_NetworkScene.GetNetworkIdentity(msg.netId, out localNetworkIdentity))
{ {
// this object already exists (was in the scene), just apply the update to existing object // this object already exists (was in the scene), just apply the update to existing object
localNetworkIdentity.Reset();
ApplySpawnPayload(localNetworkIdentity, msg.position, msg.payload, msg.netId, null); ApplySpawnPayload(localNetworkIdentity, msg.position, msg.payload, msg.netId, null);
return; return;
} }
@ -481,6 +482,7 @@ static void OnObjectSpawnScene(NetworkMessage netMsg)
if (s_NetworkScene.GetNetworkIdentity(msg.netId, out localNetworkIdentity)) if (s_NetworkScene.GetNetworkIdentity(msg.netId, out localNetworkIdentity))
{ {
// this object already exists (was in the scene) // this object already exists (was in the scene)
localNetworkIdentity.Reset();
ApplySpawnPayload(localNetworkIdentity, msg.position, msg.payload, msg.netId, localNetworkIdentity.gameObject); ApplySpawnPayload(localNetworkIdentity, msg.position, msg.payload, msg.netId, localNetworkIdentity.gameObject);
return; return;
} }
@ -499,6 +501,7 @@ static void OnObjectSpawnScene(NetworkMessage netMsg)
} }
if (LogFilter.logDebug) { Debug.Log("Client spawn for [netId:" + msg.netId + "] [sceneId:" + msg.sceneId + "] obj:" + spawnedId.gameObject.name); } if (LogFilter.logDebug) { Debug.Log("Client spawn for [netId:" + msg.netId + "] [sceneId:" + msg.sceneId + "] obj:" + spawnedId.gameObject.name); }
spawnedId.Reset();
ApplySpawnPayload(spawnedId, msg.position, msg.payload, msg.netId, spawnedId.gameObject); ApplySpawnPayload(spawnedId, msg.position, msg.payload, msg.netId, spawnedId.gameObject);
} }