From 5dc8c64a6a44900a28b23b4c030815e26a783762 Mon Sep 17 00:00:00 2001 From: "eric.boise" Date: Tue, 5 Mar 2019 17:19:13 -0800 Subject: [PATCH] pedestrian bug fix --- Assets/Scripts/Driving/PedestrianManager.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Assets/Scripts/Driving/PedestrianManager.cs b/Assets/Scripts/Driving/PedestrianManager.cs index d6a5f037..83ae21f7 100644 --- a/Assets/Scripts/Driving/PedestrianManager.cs +++ b/Assets/Scripts/Driving/PedestrianManager.cs @@ -91,13 +91,13 @@ public void OptimizePedestrians() // get ped per seg count segInView.Clear(); - foreach (var seg in pedSegments) + for (int i = 0; i < pedSegments.Count; i++) { - for (var i = 0; i < seg.segment.targetWorldPositions.Count; i++) + for (var j = 0; j < pedSegments[i].segment.targetWorldPositions.Count; j++) { - if (CheckPositionInView(seg.segment.targetWorldPositions[i])) + if (CheckPositionInView(pedSegments[i].segment.targetWorldPositions[j])) { - segInView.Add(seg); + segInView.Add(pedSegments[i]); break; // found a seg within threshold so add to segInView list } } @@ -106,17 +106,17 @@ public void OptimizePedestrians() pedPerSegmentCount = Mathf.FloorToInt(pedTotalCount / segInView.Count); // check if ped can be made active - foreach (var seg in segInView) + for (int i = 0; i < segInView.Count; i++) { - for (var i = 0; i < seg.segment.targetWorldPositions.Count; i++) + for (var j = 0; j < segInView[i].segment.targetWorldPositions.Count; j++) { - if (CheckPositionInView(seg.segment.targetWorldPositions[i])) + if (CheckPositionInView(segInView[i].segment.targetWorldPositions[j])) { - int addCount = pedPerSegmentCount - seg.transform.childCount; + int addCount = pedPerSegmentCount - segInView[i].transform.childCount; if (addCount > 0) { - for (int j = 0; j < addCount; j++) - SpawnPedestrian(seg); + for (int k = 0; k < addCount; k++) + SpawnPedestrian(segInView[i]); } break; // found a waypoint within threshold so spawn at this seg }