Search Unity

Making a grid based game

Discussion in 'Getting Started' started by cupcakehox, Jun 5, 2018.

  1. cupcakehox

    cupcakehox

    Joined:
    May 11, 2018
    Posts:
    3
    Hello guys,

    I am pretty new to Unity.I want to start building a game like Perilous Path.Connecting two random dots on a grid with a line by avoiding mines.Here's the link of the game
    .I am struggling to actually start doing something.Can someone point me in the right direction, like how do I create the grid in which i'll have to connect those two random dots.How do I draw the connecting line, etc?And the game is supposed to be in 2D.Any help would be appreciated.

    Thanks in advance
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,411
    maybe using the 2D tilemap would be easy start, to get grid and allowing user to click on it
    https://docs.unity3d.com/Manual/Tilemap.html

    but to get started, you could also just create 2D gameobject array,
    instantiate objects to it with for loops:
    Code (CSharp):
    1. for (int x=0;x<7;x++)
    2. {
    3. for (int y=0;y<7;y++)
    4. {
    5. // instantiate to x,y position
    6. // place that object in the 2D array... mygrid[x,y] = instantiatedObject
    7. }
    8. }
    9.  
     
  3. cupcakehox

    cupcakehox

    Joined:
    May 11, 2018
    Posts:
    3
    Ye i started experimenting with this new feature of Unity, i made my 6x6 grid, brushed it in the Tile Palette but how do i make it that to allow the user to click on the tiles?
     
  4. sinjinn

    sinjinn

    Joined:
    Mar 31, 2019
    Posts:
    149
    Did you figure this out?