Skip to content

Commit

Permalink
Update Gridmaps page for 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
skyace65 committed Feb 7, 2025
1 parent cb0009a commit a52694e
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 31 deletions.
Binary file removed tutorials/3d/img/gridmap_create_body.png
Binary file not shown.
Binary file added tutorials/3d/img/gridmap_create_body.webp
Binary file not shown.
Binary file added tutorials/3d/img/gridmap_dropdown.webp
Binary file not shown.
Binary file removed tutorials/3d/img/gridmap_export.png
Binary file not shown.
Binary file added tutorials/3d/img/gridmap_export.webp
Binary file not shown.
Binary file removed tutorials/3d/img/gridmap_main.png
Binary file not shown.
Binary file removed tutorials/3d/img/gridmap_menu.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed tutorials/3d/img/gridmap_mesh_scene.png
Binary file not shown.
Binary file added tutorials/3d/img/gridmap_mesh_scene.webp
Binary file not shown.
Binary file removed tutorials/3d/img/gridmap_meshlibrary1.png
Binary file not shown.
Binary file added tutorials/3d/img/gridmap_meshlibrary1.webp
Binary file not shown.
Binary file added tutorials/3d/img/gridmap_panel.webp
Binary file not shown.
Binary file removed tutorials/3d/img/gridmap_select.png
Binary file not shown.
Binary file removed tutorials/3d/img/gridmap_shift_axis.png
Binary file not shown.
110 changes: 79 additions & 31 deletions tutorials/3d/using_gridmaps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ To learn how GridMaps work, start by downloading the sample project:
`gridmap_starter.zip <https://github.com/godotengine/godot-docs-project-starters/releases/download/latest-4.x/gridmap_starter.zip>`_.

Unzip this project and add it to the Project Manager using the "Import"
button.
button. You may get a popup saying that it needs to be converted to a newer Godot
version, click **Convert project.godot**.

Creating a MeshLibrary
----------------------
Expand All @@ -31,7 +32,7 @@ To begin, you need a :ref:`class_MeshLibrary`, which is a collection
of individual meshes that can be used in the gridmap. Open the "mesh_library_source.tscn"
scene to see an example of how to set up the mesh library.

.. image:: img/gridmap_meshlibrary1.png
.. image:: img/gridmap_meshlibrary1.webp

As you can see, this scene has a :ref:`class_Node3D` node as its root, and
a number of :ref:`class_MeshInstance3D` node children.
Expand All @@ -46,14 +47,14 @@ You can manually assign a :ref:`class_StaticBody3D` and
:ref:`class_CollisionShape3D` to each mesh. Alternatively, you can use the "Mesh" menu
to automatically create the collision body based on the mesh data.

.. image:: img/gridmap_create_body.png
.. image:: img/gridmap_create_body.webp

Note that a "Convex" collision body will work better for simple meshes. For more
complex shapes, select "Create Trimesh Static Body". Once each mesh has
a physics body and collision shape assigned, your mesh library is ready to
be used.

.. image:: img/gridmap_mesh_scene.png
.. image:: img/gridmap_mesh_scene.webp


Materials
Expand Down Expand Up @@ -117,42 +118,89 @@ Exporting the MeshLibrary
To export the library, click on **Scene > Export As... > MeshLibrary...**, and save it
as a resource.

.. image:: img/gridmap_export.png
.. image:: img/gridmap_export.webp

You can find an already exported MeshLibrary in the project named "MeshLibrary.tres".

Using GridMap
-------------

Create a new scene and add a GridMap node. Add the mesh library by dragging
the resource file from the FileSystem dock and dropping it in the "Theme" property
the resource file from the FileSystem dock and dropping it in the "Mesh Library" property
in the Inspector.

.. image:: img/gridmap_main.png

The "Cell/Size" property should be set to the size of your meshes. You can leave
it at the default value for the demo. Set the "Center Y" property to "Off".

Now you can start designing the level by choosing a tile from the palette and
placing it with Left-Click in the editor window. Use Right-click to remove a tile.

Use the arrows next to the "GridMap" menu to change the floor that you are working on.

Click on the "GridMap" menu to see options and shortcuts. For example, pressing
:kbd:`S` rotates a tile around the y-axis.

.. image:: img/gridmap_menu.png

Holding :kbd:`Shift` and dragging with the left mouse button will draw a selection
box. You can duplicate or clear the selected area using the respective menu
options.

.. image:: img/gridmap_select.png

In the menu, you can also change the axis you're drawing on, as well as shift
the drawing plane higher or lower on its axis.

.. image:: img/gridmap_shift_axis.png
.. image:: img/gridmap_mesh_library_inspector.webp

Inspector properties
~~~~~~~~~~~~~~~~~~~~

The **Physics Material** setting allows you to override the physics material for
every mesh in the NavigationMesh.

Under **Cells** the size property should be set to the size of your meshes. You can
leave it at the default value for the demo. Set the "Center Y" property to "Off".

The Collision options allow you to set the collision layer, collision mask, and
priority for the entire grid. For more information on how those work see the
:ref:`physics section<doc_physics_index>`__ of the docs.

Under **Navigation** is the "Bake Navigation" option, if enabled it creates a
navigation region for each cell that uses a mesh_library item with a navigation
mesh.

If you click on the MeshLibrary itself in the inspector you can adjust settings for
individual meshes, such as their navigation mesh, navigation layers, or if the mesh
casts shadows.

.. image:: img/gridmap_mesh_library_settings.webp

GridMap panel
~~~~~~~~~~~~~

At the bottom of the editor is the GridMap panel, which should have opened
automatically when you added the GridMap node.

.. image:: img/gridmap_panel.webp

From left to right in the toolbar:

- **Transform**: Adds a gizmo to the scene that allows you to change the
relative position and rotation of the gridmap in the scene.
- **Selection**: While active you can select an area in the viewport, click and drag
to select more than one space on the grid.
- **Earase**: While active, click in the viewport and delete meshes.
- **Paint**: While active, click in the viewport and add whatever mesh is currently
selected in the GridMap panel to the scene.
- **Pick**: While active, clicking on a gridmap mesh in the viewport will cause
it to be selected in the GridMap panel.
- **Fill**: Fill the area that has been selected in the viewport with whatever mesh
is selected in the GridMap bottom panel.
- **Move**: Move whatever mesh or meshes are currently selected in the viewport.
- **Duplicate**: Create a copy of whatever the selected mesh or meshes in the
GridMap are.
- **Delete**: Similar to erase, but for the entire selected area.
- **Cursor Rotate X**: While the paint tool is selected, this will rotate the mesh
that will be painted on the X axis. This will also rotate selected areas if they
are being moved.
- **Cursor Rotate Y**: While the paint tool is selected, this will rotate the mesh
that will be painted on the Y axis. This will also rotate selected areas if they
are being moved.
- **Cursor Rotate Z**: While the paint tool is selected, this will rotate the mesh
that will be painted on the Z axis. This will also rotate selected areas if they
are being moved.
- **Change Grid Floor**: adjusts what floor is currently being worked on, can be
changed with the arrows or typing
- **Filter Meshes**: used to search for a specific mesh in the bottom panel.
- **Zoom**: controls the zoom level on meshes in the bottom panel
- **Layout toggles**: These two buttons toggle between different layouts for meshes
in the bottom panel.
- **Tools dropdown**: This button opens a dropdown menu with a few more options.

.. image:: img/gridmap_dropdown.webp

Clicking on **Settings** in that dropdown brings up a window that allows you to
change the pick distance, this is the maximum distance at which tiles can be placed
on a GridMap, relative to the camera position (in 3D units).

Using GridMap in code
---------------------
Expand Down

0 comments on commit a52694e

Please sign in to comment.