Gridmaps are a tool for creating 3D game levels, similar to the way TileMap works in 2D.
You start with a predefined collection of 3D meshes (a MeshLibrary) that can be placed on a grid, as if you were building a level with an unlimited amount of Lego blocks.
Collisions and navigation can also be added to the meshes, just like you would do with the tiles of a tilemap.
Start by creating a folder for the mesh library
In the FileSystem right click and create folder called MeshLibraries
Right-click on the MeshLibraries folder
(This is the library of spaces / tiles we can place in the GridMap
In the new SpaceLibrary Scene
Add a MeshInstance3D as a child
Rename the MeshInstace3D to FreeSpace
Since these blocks represent free spaces on the map
In the Mesh property of the MeshInstance3D
Set the dimensions as shown
Add a new StandardMaterial and click on the material to open it
Find the Albedo property and change the colour to a light grey
Add Collisions to the Mesh
Click on the Mesh button in the viewport
Then Click on Create Collision Shape
Your Scene Tree now looks like this
In the SpaceLibrary Scene
Add a MeshInstance3D as a child
Rename the MeshInstace3D to TurretBase
Since these blocks represent spaces on the map
where we can place turrets
In the Mesh property of the MeshInstance3D
Set the dimensions as shown
Add a new StandardMaterial and click on the material to open it
Find the Albedo property and change the colour to a light red
Add Collisions to the Mesh
Click on the Mesh button in the viewport
Then Click on Create Collision Shape
Your Scene Tree now looks like this
Now we will export this scene as a MeshLibrary
Save it as SpaceLibrary.tres
in the MeshLibraries folder
Now we can use our meshes in a GridMap
In the Mesh Library Property
Quick Load or Drag and Drop
The SpaceLibrary.tres file
Now you can choose the tiles from the GridMap
At the bottom of the screen