Quantcast
Viewing all articles
Browse latest Browse all 2891

IndexOutOfRangeException: Array index is out of range

I have a GameObject[] called walkways and it's giving me an "Array index is out of range" error code despite the fact that I have the call maximum as "walkways.Length." using System.Collections; using System.Collections.Generic; using UnityEngine; public class spawnwalkway : MonoBehaviour { public GameObject[] walkways; public int plat_num_random; // Use this for initialization void Start () { StartCoroutine(spawnBlock()); } // Update is called once per frame void Update () { } IEnumerator spawnBlock() { walkways = GameObject.FindGameObjectsWithTag("walkway"); for (int z = 1; z < 100; z++) { Instantiate(walkways[Random.Range(0,walkways.Length)], new Vector3(-1.42637f, -0.4771186f, 2 * z + 8.574288f), Quaternion.identity); yield return new WaitForSeconds(0.5f); } } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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