Skip to content

Instantly share code, notes, and snippets.

@CodeZombie
Created October 3, 2020 21:05
Show Gist options
  • Save CodeZombie/09195cd1ac2b4bdb9f51bb51341865e1 to your computer and use it in GitHub Desktop.
Save CodeZombie/09195cd1ac2b4bdb9f51bb51341865e1 to your computer and use it in GitHub Desktop.
How to: Create a 3d Gridmap in Godot 3.2
Section A: Preparing your models in Blender.
1. In blender, open up one of your 3d tiles.
2. Center it in the scene and have it sit directly above y=0
3. Export it as a .obj file
Repeat these steps for every tile in the tileset.
Section B: Setup in Godot
1. Create a new scene with a spatial node.
2. Create a new folder called "Models" and drag your .obj files in there.
3. Drag all your models into the scene as children of Spatial. They should all be of type MeshInstance.
4. Select each MeshInstance node and at the top of the viewport, click "Mesh -> Create Trimesh Static Body"
5. Next, for each MeshInstance node, open the Material property and click "[empty] -> New Shader Material"
6. Click the new shader material to open up its inpector. Then, next to 'Shader', click "[empty] -> New VisualShader"
7. Create a new folder called "Textures" and drag all the texture files into it.
8. Drag the corresponding texture for this specific model and connect its RGB to Albedo. Here is where you'll import and connect normals as well.
9. If this material will be used by mutliple models, at the top of the inspector you can save the texture. Save it in a new "Materials" folder.
10. When you're happy with all your tiles, save the scene, then click "Scene -> Convert To -> Mesh Library". Save it as something like "MyTiles.meshlib" (You'll have to repeat this step any time you make a change to the tiles in this scene.
Section C: Using the Gridmap.
1. In your game scnee, create a new GridMap node.
2. In the inspector, load your *.meshlib file in the MeshLib field.
3. That's it, you can now start drawing your world.
Hint: Press "s" to rotate tiles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment