MirrorTest: fix CreateNetworkedAndSpawnPlayer not properly spawning because the GO wasn't considered for spawning because it wasn't inactive

This commit is contained in:
vis2k 2022-02-02 12:40:42 +08:00
parent badde10c1d
commit 9512b8f0e6

View File

@ -415,6 +415,11 @@ protected void CreateNetworkedAndSpawnPlayer(
clientIdentity.sceneId = serverIdentity.sceneId = (ulong)serverGO.GetHashCode();
NetworkClient.spawnableObjects[clientIdentity.sceneId] = clientIdentity;
// IMPORTANT: OnSpawn finds 'sceneId' in .spawnableObjects.
// only those who are ConsiderForSpawn() are in there.
// for scene objects to be considered, they need to be disabled.
clientGO.SetActive(false);
// add as player & process spawn message on client.
NetworkServer.AddPlayerForConnection(ownerConnection, serverGO);
ProcessMessages();