Hello everyone,
I’m trying to refer to a certain bool array and I’m getting the error : IndexOutOfRangeException: Array index is out of range. What’s wrong with it?
using UnityEngine;
using System.Collections;
public class Level : MonoBehaviour
{
public GameObject[] blocksPrefabs;
public GameObject[] comboPrefabs;
public Transform defaultSpawn;
public Transform comboSpawn;
public float startDelay=0;
public float intervals=0;
public bool[] comboCheck;
//false should be shapes, true should be colors
bool mode = false;
float successRatio = 0.0f;
float gameStart = 0.0f;
float range = 2.6f;
[HideInInspector]
public float goodPitch = 0.6f;
[HideInInspector]
public int pitchStacks = 0;
[HideInInspector]
public int Combo = 0;
[HideInInspector]
public int totalLanded = 0;
[HideInInspector]
public int totalSuccess=0;
void Start ()
{
InvokeRepeating ("InstantiateBlock", startDelay, intervals);
}
void InstantiateBlock ()
{
Vector3 Spawn = new Vector3 (Random.Range (-range, range), 6f, 0);
GameObject Shapes = Instantiate(blocksPrefabs[Random.Range (0,blocksPrefabs.Length)], Spawn, defaultSpawn.rotation) as GameObject;
}
void Update ()
{
if (totalLanded >= 1) {
successRatio = ((float)totalSuccess / (float)totalLanded)*100;
Debug.Log (successRatio);
}
if (Combo >= 5 && comboCheck[0] == false) {
comboCheck[0]=true;
GameObject Combos = Instantiate(comboPrefabs[0], comboSpawn.position, comboSpawn.rotation) as GameObject;
}
[code]