Search Unity

Game Grid Editor

Discussion in 'Scripting' started by Studio_Akiba, Oct 13, 2015.

  1. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    I have been planning a grid-based mapping system for a while now, but have been working hard in Substance Designer working on the textures until now so haven't been able to donate much time to it (it's just been an idea on the whiteboard for a while).

    I am making a modern style dungeon crawler, the levels to which are largely grid-based for ease of traversing and mapping, so a dungeon editor (and saver) was not out of the question.

    I am looking for a top-down designer that will allow me to place walls and doors on edges and objects such as tables, characters, npc's and other elements in the grid squares, but don't know where to begin with this.

    The idea is that even the levels that come with the game will be based on this system eventually, so the dungeon files will be generic and the levels generated from the dungeon files (preventing the need for a large game size).

    I am unsure of how viable this is, and wanted to get some people's opinions on how this could be achieved.
     
  2. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    Essentially a tile editor boils down to
    • detect mouse input position
    • round x and y (or z) values to integers
    • assign tile ID to map array[x,y]
    • instantiate some prefab at that position
    Then you just need to save the array of ints
    Thats for floor tiles.
    Wall generation can be handled autmomagically without user interaction using an algo to check if an open floor space has adjacent floor spaces up/down/left/right or combinations thereof, and picking 1 of 16 prefabs (eg: )
    [And theres some clever bitwise math you can do to make this easy]