Hey, i have so problems with the Instantiate function

using UnityEngine;

public class Grid{

private int width;
private int height;
private GameObject thing;
private int[,] gridArray;

public Grid(int width, int height, GameObject thing, float distance){
this.width = width;
this.height = height;
this.thing = thing;

gridArray = new int[width,height];

for (int x=0; x<gridArray.GetLength(0); x++){
for (int y=0; y<gridArray.GetLength(1); y++){
Instantiate(thing, new Vector3(distance * x, 0, distance * y), thing.transform.rotation);
}
}

}

}

So, what’s the problem?

1 Like

It gives me an error, it says that “The name Instantiate does not exist in the current context”

Instantiate actually refers to Object.Instantiate, to which you have access by inheriting the Unity Object. Most commonly by inheriting from Monobehaviour, which you dont. Or in other words: yes, the name Instantiate does not exist in the current context indeed.

1 Like

So

Thanks!

1 Like