Generating the 2d world grid

Summary

The World Generator Window uses Unity Editor Window API to render a window that controls generation of the grid. You can find this window under Window/RL World Generator.

The generator instantiates the Tile_Parent prefab at every point in the grid you specify, maintaining a distance between tiles according to what you specify (see parameters below). This window is only for use while Unity is NOT in play mode. When you have finished entering parameters and are ready to generate the grid, hit the Generate Grid button. You should end up with a result like this:

Note: I’ve manually modified some of these tiles; you may only get a grid of plain tiles when you generate.

Parameters

  • Number of tiles on the X-Axis
  • Number of tiles on the Z-Axis
  • Distance between tiles (X-Axis) – This specifies how far apart tiles are +/- X-Axis direction
  • Distance between tiles (Z-Axis) – This specifies how far apart tiles are +/- Z-Axis direction
  • Tile Manager Obj – Drag and drop the Tile_Manager_RL2D from the scene to here.
  • Tile Obj – Drag and drop the Tile_Parent from the Assets/Resources/2D_World_Gen_Prefabs folder to this variable.

Buttons

  • Generate World – Destroys the current world and makes a new one
  • Destroy World – Destroys the current world

Assets Involved

  • Assets/Resources/2D_World_Gen_Prefabs/Tile_Parent – The prefab that makes up each tile (Tile-wide actions are managed here)
  • Assets/Resources/2D_World_Gen_Prefabs/Tile_Manager_RL2D – The prefab that acts as a parent to the entire grid (Grid-wide actions are managed here)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: