fix: Round Robin Spawning by Hierarchy Order (#790)

Fixes #724
This commit is contained in:
MrGadget 2019-04-10 06:34:14 -04:00 committed by vis2k
parent f46f32df55
commit 531e202bbe

View File

@ -508,6 +508,12 @@ public static void RegisterStartPosition(Transform start)
{ {
if (LogFilter.Debug) Debug.Log("RegisterStartPosition: (" + start.gameObject.name + ") " + start.position); if (LogFilter.Debug) Debug.Log("RegisterStartPosition: (" + start.gameObject.name + ") " + start.position);
startPositions.Add(start); 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) public static void UnRegisterStartPosition(Transform start)