From 531e202bbec43d855b0ba24e445588fda2f08102 Mon Sep 17 00:00:00 2001 From: MrGadget Date: Wed, 10 Apr 2019 06:34:14 -0400 Subject: [PATCH] fix: Round Robin Spawning by Hierarchy Order (#790) Fixes #724 --- Assets/Mirror/Runtime/NetworkManager.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Assets/Mirror/Runtime/NetworkManager.cs b/Assets/Mirror/Runtime/NetworkManager.cs index 808c34a43..99f6f7f83 100644 --- a/Assets/Mirror/Runtime/NetworkManager.cs +++ b/Assets/Mirror/Runtime/NetworkManager.cs @@ -508,6 +508,12 @@ public static void RegisterStartPosition(Transform start) { if (LogFilter.Debug) Debug.Log("RegisterStartPosition: (" + start.gameObject.name + ") " + start.position); startPositions.Add(start); + + // reorder the list so that round-robin spawning uses the start positions + // in hierarchy order. This assumes all objects with NetworkStartPosition + // component are siblings, either in the scene root or together as children + // under a single parent in the scene. + startPositions = startPositions.OrderBy(transform => transform.GetSiblingIndex()).ToList(); } public static void UnRegisterStartPosition(Transform start)