Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Im getting Index was out of range. Must be non negative and less than the size of the collection.

$
0
0
So im getting the error message and i've looked it at online and it says i need to declare how many spaces the list has. However i cant figure out where where to do that. public int uran = 0, uranu= 0, child, childe; public float cooldown = 10, warning_cooldwon = 5; GameObject warning1, warning2, laser1, laser2; new List warnings = new List(); new List lasers = new List(); // Start is called before the first frame update void Start() { laser_shot(); } public void laser_shot() { Debug.Log("notw"); uran= Random.Range(0, 5); uranu= Random.Range(0, 5); child = Random.Range(0, 5); childe = Random.Range(0, 5); warning1 = warnings[uranu].gameObject; warning2 = warnings[uran].gameObject; laser1 = lasers[childe].gameObject; laser2 = lasers[child].gameObject; cooldown -= 0.1f; warning_cooldwon -= 0.05f; StartCoroutine(fire_laser()); } // Update is called once per frame void Update() { foreach (GameObject yeet in GameObject.FindGameObjectsWithTag("Warning")) { warnings.Add(yeet); } foreach (GameObject yoot in GameObject.FindGameObjectsWithTag("Laser")) { lasers.Add(yoot); } } Any help is appreciated.

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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