Unity Question

Hey so I’ve been looking to create a game where the player is a snake. I’m trying to make a wall with a custom grid size where I could be able to change the grid size dynamically from the inspector. I’ve been scratching my head about this one as I’ve not been able to figure it out. I’m planning to place tiles which turn green as soon the snake touches it. Can someone please help me out?

Hi,

To generate a grid, you could use two for-loops, one for the width, one for the height.

Did this help?


See also:

Can you please show me how the code is written? Sorry I’m pretty new to this

for (int i = 0; i < yourgridWidth; i++)
{
    for (int j = 0, j < yourGridHeight; j++)
    {
        // your code
    }
}

If this did not help, please feel free to ask our helpful community of students for further advice over on our Discord chat server.

Thank you for your help

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms