I am having 4 angles that is stored in an array:
90 180 270 360
I am using one of these when a trigger gets activated. However I am getting an error saying index was outside the bounds. Why is this happening?
public float[] rotateAngles;
int i = 0;
public void OnTriggerEnter (Collider col) {
if (!enabled) return;
Rotate ();
}
public void Rotate(){
transform.eulerAngles = new Vector3(transform.eulerAngles.x, rotateAngles[i], transform.eulerAngles.z);
i++;
if(i>rotateAngles.Length){
i = 0;
}
}