Hello, I’m trying to generate a background, but the class that generates the background is unable to see how big the map is: the static variable stored in the class GameManage. I can access this variable from all other classes, and in all other classes it is correct, but the background generator for some reason thinks that it is always 0. Does anyone have any idea what’s going on?
public void Spawn()
{
int xMaxMin = Mathf.Round(GameManage.maxSize * GameManage.aspectRatio) + buffer;
int yMaxMin = GameManage.maxSize + buffer;
float xCoord = -xMaxMin;
float yCoord = -yMaxMin;
for (int i = -xMaxMin; i < xMaxMin; i ++)
{
if (xCoord > xMaxMin) break;
for (int j = -yMaxMin; j < yMaxMin; j ++)
{
if (yCoord > yMaxMin) break;
Instantiate(gameObject).transform.position = new Vector3(xCoord, yCoord, 0);
yCoord += size;
}
xCoord += size;
yCoord = -yMaxMin;
}