Quantcast
Channel: Latest Questions by Griffo
Viewing all articles
Browse latest Browse all 94

Why is my list bigger than it should be?

$
0
0
I'm generating 3 random waypoints then saving them to a list but when debugged the list is showing a Count of 5, why? function getWaypionts () { for (var l=0; l < 3; l++) { Debug.Log("l is " + l); var walkRadius : float = 10; var randomDirection : Vector3 = Random.insideUnitSphere * walkRadius; randomDirection += transform.position; var hit : NavMeshHit; NavMesh.SamplePosition(randomDirection, hit, walkRadius, 1); var finalPosition : Vector3 = hit.position; waypoints.Add(finalPosition); } for (var lk=0; lk < waypoints.Count; lk++) { Debug.Log("waypoint " + lk + " is " + waypoints[lk]); } waypointsGenerated = true; } ![alt text][1] [1]: /storage/temp/65207-screen-shot-2016-03-04-at-131545.png

Viewing all articles
Browse latest Browse all 94

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>