I am trying to create 2 Vector 3 arrays, one to hold positions and one to hold rotations. The issue is on the first line of the start function. I get the error…
IndexOutOfRangeException: Array index is out of range.
CheckpointPos.Start () (at Assets/Scripts/CheckpointPos.cs:18)
I’ve looked around the forums to find answers but I can’t find anything that works =(
I also discovered if I try to edit the size of the array in the inspector, it automatically resets to 0. Any help appreciated and I’ll try answer any questions/clarify anything.
public Vector3[] SpawnPos = new Vector3[8];
public Vector3[] SpawnRot = new Vector3[8];
void Start(){
SpawnPos [0] = new Vector3 (-11.4f, 5.2f, 10.8f);
SpawnRot [0] = new Vector3 (335.8f, 0f, 0);
SpawnPos [1] = new Vector3 (-11.4f, 19.4f, 23.4f);
SpawnRot [1] = new Vector3 (305.9f, 0f, 0f);
SpawnPos [2] = new Vector3 (-11.4f, 25.4f, 40.2f);
SpawnRot [2] = new Vector3 (2.2f, 0f, 0f);
SpawnPos [3] = new Vector3 (-11.4f, 21.6f, 57.4f);
SpawnRot [3] = new Vector3 (32.7f, 0f, 0f);
SpawnPos [4] = new Vector3 (-11.4f, 5.3f, 75.9f);
SpawnRot [4] = new Vector3 (90f, 0f, 0f);
SpawnPos [5] = new Vector3 (-11.4f, -13.0f, 57.2f);
SpawnRot [5] = new Vector3 (51.3f, 185.5f, 184.8f);
SpawnPos [6] = new Vector3 (-11.4f, -13.0f, 57.2f);
SpawnRot [6] = new Vector3 (51.3f, 185.5f, 184.8f);
SpawnPos [7] = new Vector3 (-11.4f, -11.1f, 12.3f);
SpawnRot [7] = new Vector3 (51.3f, 0f, 0f);
}