Hi all, I’ve seen a couple questions with this error. But I am not sure what exactly is going on. I’m pretty sure I have “news” in all the right spots but it just doesn’t want to take it.
I’m using a 2D array (a 9x9 grid) to store a spawn points in a grid for a prefab. I also need to keep track if something is on in the grid, thus I made a custom class:
public class gridSpawn {
GameObject prefab;
public bool on;
Vector3 pos;
public gridSpawn( GameObject n, Vector3 b ){
prefab = n;
pos = b;
}
bool toggleOn(){ // toggles on, returns if val of on
on = !on;
return on;
}
void spawn(){
GameObject.Instantiate(prefab, pos, Quaternion.identity);
}
}
I’m setting up the grid in my start function in the main class for the script:
public class SpawnGrid : MonoBehaviour {
public GameObject pre = new GameObject();
private gridSpawn[,] grid;
// Use this for initialization
void Start () {
grid = new gridSpawn[9,9];
for( int i = 0; i < 9; i++ )
{
for( int z = 0; z < 9; z++ )
gridSpawn_[z] = new gridSpawn( pre, new Vector3( i * 20 - 90 , z * -20 + 90, 80 ) );_
}
}
// Update is called once per frame
void Update () {
}
}
The line in question is gridSpawn*[z], I just don’t see what I’m missing. The news are there, but it seems to suggest that pre somehow needs to be “new” yet it’s a member of the class…*
Anyway. I apologize for the formatting, it’s durdling hard.