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

What does IndexOutOfRangeException: Array index is out of range mean?

$
0
0
I am doing a Unity tutorial and have run into an error. OutofRangeException : Array index is out of range. What does this mean and how do i fix it? Here is my code : #pragma strict //Enemy Script //Inspector Variables var shapeColor : Color[]; var numberOfClicks : int = 2; var respawnWaitTime : float = 2.0; //Private Variables //Update is called every frame function Update () { if (numberOfClicks <= 0) { var position = Vector3 (Random.Range(-6,6),Random.Range(-4,4),0);//creates random position RespawnWaitTime(); transform.position = position; //moves game object to a new position numberOfClicks = 2; } } //RespawnWaitTime is used to hide game object for a set amount of time and then unhide it. function RespawnWaitTime () { renderer.enabled = false; RandomColor(); yield WaitForSeconds (respawnWaitTime); renderer.enabled = true; } //RandomColor used to changematerial of a game object. function RandomColor () { var newColor = Random.Range(0, shapeColor.length); renderer.material.color = shapeColor[newColor]; }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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