- Home /
Keeping instantiated grid in the centre of the screen?
HI, everyone, I'm making a mobile game and I need help.
In the game, I instantiate a grid of dots as seen in the first attached file below.
My problem is the grid is not in the centre of the screen
I could just position my main camera so the grid is in the centre the only problem with this approach being that the grid changes in size depending on your level as shown in attachment 2
here's my spawn code
for (int x = 0; x < gridX; x++)
{
for (int y = 0; y < gridY; y++)
{
SpawnDelay = Random.Range(0.2f, 0.5f);
yield return new WaitForSeconds(SpawnDelay);
Instantiate(Dot, transform.position, transform.rotation);
NumberOfdots++;
transform.position = new Vector2(transform.position.x + distanceBetween, transform.position.y);
if (y % MutpleNum == ByMutpleNum)
{
transform.position = new Vector2(GridoffsetX/2, transform.position.y + GridoffsetY);
}
}
}
Is there anyway I can have the grid centre regardless of its size
Thanks,
David
PS. it's possible I'm just missing a simple solution :)
[1]: /storage/temp/122161-2018-08-05-12-37-45-unity-201821f1-personal-64bit.png
Your answer
Follow this Question
Related Questions
Send data from Android to Arduino via RPi 3 WiFi 0 Answers
Multiple Cars not working 1 Answer
how to make my game for all screen please ? 1 Answer
Distribute terrain in zones 3 Answers