Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Best way to Make a Grid based game

Discussion in 'Getting Started' started by Clawedatom, Jan 16, 2023.

  1. Clawedatom

    Clawedatom

    Joined:
    Mar 27, 2022
    Posts:
    5
    I am currently attempting to make a dungeon type game where each level is randomly generated.
    To do this I use a grid where I pick a few random spots where I want a room. I have done this part but im wondering what the best way is to link them up with hallways in the way that they generate with them using pathfinding for the hallways for something.
    Thanks
     
  2. AngryProgrammer

    AngryProgrammer

    Joined:
    Jun 4, 2019
    Posts:
    490
    You can do everything as much as possible with the Grid and Tilemap component.

    I rather prefer to use something simple to generate and store the data, i.e. a structure consisting of a width and a list of integers. Why do I need width? For navigating a one-dimensional list like two-dimensional (its width of the row). Why is it one dimensional? This is due to the limitations of JsonUtility because I store everything in JSON.

    All operations for world generation, world data storage, and pathing are done in this list. And only the result is translated into a visual effect using Unity components.