Hello,
I declared an array with a fixed size of 4, but when I try to change the value I get an index out of range error, really not sure why.
I get the error at this line
map_start_x[1] = ((float)map_tiles_width * 10) + map_start_x[0];
Any suggestions?
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class World : MonoBehaviour
{
public bool show_debug = false;
public bool[] regenerate_world = { false, false, false, false };
public GameObject[] maps;
public int map_tiles_width;
public int map_tiles_height;
public float[] map_start_x = new float[4];
public float[] map_start_z = new float[4];
void Start()
{
MapPlacementCoordinates();
}
private void MapPlacementCoordinates()
{
map_start_x[0] = 0f;
map_start_z[0] = 0f;
map_start_x[1] = ((float)map_tiles_width * 10) + map_start_x[0];
map_start_z[1] = map_start_z[0];
map_start_x[2] = map_start_x[0];
map_start_z[2] = ((float)map_tiles_height * 10) + map_start_x[0];
map_start_x[3] = ((float)map_tiles_width * 10) + map_start_x[0];
map_start_z[3] = ((float)map_tiles_height * 10) + map_start_x[0];
maps[0].transform.position = new Vector3(map_start_x[0], 0f, map_start_z[0]);
maps[1].transform.position = new Vector3(map_start_x[1], 0f, map_start_z[1]);
maps[2].transform.position = new Vector3(map_start_x[2], 0f, map_start_z[2]);
maps[3].transform.position = new Vector3(map_start_x[3], 0f, map_start_z[3]);
}
}