- Home /
Grid Based Question
Hello! So I'm new to Unity, and I've been diligently working on the official tutorials, reading the documentation, and some other third party books in an attempt to create a game like Megaman Battle Network in the distant future. My BIGGEST problem however, is creating the main game board. In MMBN, players move in real time on their own 3x3 grids, which change dynamically change as the game goes on. Tiles can break or get stolen by other players, so a match can switch from a 3x3 vs 3x3 board to a 3x2 vs 3x4 board, etc. I need tiles that can change properties as the game progresses, but I don't know how to go about it, conceptually. Ignoring code for now, how would you guys go about this? I was thinking some sort of array for all tiles that would hold all tiles types or something of that manner. Any thoughts? I would love your input, as it would give me a more clear route as to where I'm headed in my practice time. Thanks in advance!
Answer by InsertFunnyUsernameHere · May 14, 2015 at 05:00 PM
1 Create a Tile script responsible for changing the state of a Tile
2 create a script to handle the Tiles (BoardManager)
3 Create a script to generate the board (BoardGenerator)
4 Create an empty GameObject, rename it to Board and attach BoardManager and BoardGenerator
5 Run
Check out "Roguelike 2D" tutorial if you want more specifics
That sounds like a great idea! Could you elaborate a bit more on a script "Handling" tiles though? Define "handling". I haven't gotten to that tutorial quite yet, but almost there :)
Put a public static two-dimensional array of type Tile in your Board$$anonymous$$anager and make BoardGenerator instantiate the Tiles and fill the array with references to them something like this:
//BoardGenerator
public Tile TilePrefab;
GameObject Instance = (GameObject)Instantiate(TilePrefab,Vector3(x,y,0f),Quaternion.identity)
Board$$anonymous$$anager.TileArray[x,y]=Instance.GetComponent<Tile>();
Your answer
Follow this Question
Related Questions
Grid Movement VS Free Movement 1 Answer
How can I use the GridBrush in Unity at runtime in the game? 3 Answers
Hexagonal grid with 120 degree angles 1 Answer
Projecting a grid over a mesh 1 Answer
Highlighting Individual Tile Squares 0 Answers