:github_url: hide .. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the GridMap.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_GridMap: GridMap ======= **Inherits:** :ref:`Spatial` **<** :ref:`Node` **<** :ref:`Object` **Category:** Core Brief Description ----------------- Node for 3D tile-based maps. Properties ---------- +---------------------------------------+------------------------------------------------------------------+--------------------+ | :ref:`bool` | :ref:`cell_center_x` | true | +---------------------------------------+------------------------------------------------------------------+--------------------+ | :ref:`bool` | :ref:`cell_center_y` | true | +---------------------------------------+------------------------------------------------------------------+--------------------+ | :ref:`bool` | :ref:`cell_center_z` | true | +---------------------------------------+------------------------------------------------------------------+--------------------+ | :ref:`int` | :ref:`cell_octant_size` | 8 | +---------------------------------------+------------------------------------------------------------------+--------------------+ | :ref:`float` | :ref:`cell_scale` | 1.0 | +---------------------------------------+------------------------------------------------------------------+--------------------+ | :ref:`Vector3` | :ref:`cell_size` | Vector3( 2, 2, 2 ) | +---------------------------------------+------------------------------------------------------------------+--------------------+ | :ref:`int` | :ref:`collision_layer` | 1 | +---------------------------------------+------------------------------------------------------------------+--------------------+ | :ref:`int` | :ref:`collision_mask` | 1 | +---------------------------------------+------------------------------------------------------------------+--------------------+ | :ref:`MeshLibrary` | :ref:`mesh_library` | | +---------------------------------------+------------------------------------------------------------------+--------------------+ | :ref:`MeshLibrary` | :ref:`theme` | | +---------------------------------------+------------------------------------------------------------------+--------------------+ Methods ------- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear` **(** **)** | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear_baked_meshes` **(** **)** | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`RID` | :ref:`get_bake_mesh_instance` **(** :ref:`int` idx **)** | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`get_bake_meshes` **(** **)** | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_cell_item` **(** :ref:`int` x, :ref:`int` y, :ref:`int` z **)** const | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_cell_item_orientation` **(** :ref:`int` x, :ref:`int` y, :ref:`int` z **)** const | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`get_collision_layer_bit` **(** :ref:`int` bit **)** const | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`get_collision_mask_bit` **(** :ref:`int` bit **)** const | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`get_meshes` **(** **)** | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`get_used_cells` **(** **)** const | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`make_baked_meshes` **(** :ref:`bool` gen_lightmap_uv=false, :ref:`float` lightmap_uv_texel_size=0.1 **)** | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`map_to_world` **(** :ref:`int` x, :ref:`int` y, :ref:`int` z **)** const | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`resource_changed` **(** :ref:`Resource` resource **)** | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_cell_item` **(** :ref:`int` x, :ref:`int` y, :ref:`int` z, :ref:`int` item, :ref:`int` orientation=0 **)** | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_clip` **(** :ref:`bool` enabled, :ref:`bool` clipabove=true, :ref:`int` floor=0, Vector3.Axis axis=0 **)** | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_collision_layer_bit` **(** :ref:`int` bit, :ref:`bool` value **)** | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_collision_mask_bit` **(** :ref:`int` bit, :ref:`bool` value **)** | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`world_to_map` **(** :ref:`Vector3` pos **)** const | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Constants --------- .. _class_GridMap_constant_INVALID_CELL_ITEM: - **INVALID_CELL_ITEM** = **-1** --- Invalid cell item that can be used in :ref:`set_cell_item` to clear cells (or represent an empty cell in :ref:`get_cell_item`). Description ----------- GridMap lets you place meshes on a grid interactively. It works both from the editor and can help you create in-game level editors. GridMaps use a :ref:`MeshLibrary` which contain a list of tiles: meshes with materials plus optional collisions and extra elements. A GridMap contains a collection of cells. Each grid cell refers to a :ref:`MeshLibrary` item. All cells in the map have the same dimensions. A GridMap is split into a sparse collection of octants for efficient rendering and physics processing. Every octant has the same dimensions and can contain several cells. Tutorials --------- - :doc:`../tutorials/3d/using_gridmaps` Property Descriptions --------------------- .. _class_GridMap_property_cell_center_x: - :ref:`bool` **cell_center_x** +-----------+---------------------+ | *Default* | true | +-----------+---------------------+ | *Setter* | set_center_x(value) | +-----------+---------------------+ | *Getter* | get_center_x() | +-----------+---------------------+ If ``true``, grid items are centered on the X axis. .. _class_GridMap_property_cell_center_y: - :ref:`bool` **cell_center_y** +-----------+---------------------+ | *Default* | true | +-----------+---------------------+ | *Setter* | set_center_y(value) | +-----------+---------------------+ | *Getter* | get_center_y() | +-----------+---------------------+ If ``true``, grid items are centered on the Y axis. .. _class_GridMap_property_cell_center_z: - :ref:`bool` **cell_center_z** +-----------+---------------------+ | *Default* | true | +-----------+---------------------+ | *Setter* | set_center_z(value) | +-----------+---------------------+ | *Getter* | get_center_z() | +-----------+---------------------+ If ``true``, grid items are centered on the Z axis. .. _class_GridMap_property_cell_octant_size: - :ref:`int` **cell_octant_size** +-----------+------------------------+ | *Default* | 8 | +-----------+------------------------+ | *Setter* | set_octant_size(value) | +-----------+------------------------+ | *Getter* | get_octant_size() | +-----------+------------------------+ The size of each octant measured in number of cells. This applies to all three axis. .. _class_GridMap_property_cell_scale: - :ref:`float` **cell_scale** +-----------+-----------------------+ | *Default* | 1.0 | +-----------+-----------------------+ | *Setter* | set_cell_scale(value) | +-----------+-----------------------+ | *Getter* | get_cell_scale() | +-----------+-----------------------+ .. _class_GridMap_property_cell_size: - :ref:`Vector3` **cell_size** +-----------+----------------------+ | *Default* | Vector3( 2, 2, 2 ) | +-----------+----------------------+ | *Setter* | set_cell_size(value) | +-----------+----------------------+ | *Getter* | get_cell_size() | +-----------+----------------------+ The dimensions of the grid's cells. .. _class_GridMap_property_collision_layer: - :ref:`int` **collision_layer** +-----------+----------------------------+ | *Default* | 1 | +-----------+----------------------------+ | *Setter* | set_collision_layer(value) | +-----------+----------------------------+ | *Getter* | get_collision_layer() | +-----------+----------------------------+ .. _class_GridMap_property_collision_mask: - :ref:`int` **collision_mask** +-----------+---------------------------+ | *Default* | 1 | +-----------+---------------------------+ | *Setter* | set_collision_mask(value) | +-----------+---------------------------+ | *Getter* | get_collision_mask() | +-----------+---------------------------+ .. _class_GridMap_property_mesh_library: - :ref:`MeshLibrary` **mesh_library** +----------+-------------------------+ | *Setter* | set_mesh_library(value) | +----------+-------------------------+ | *Getter* | get_mesh_library() | +----------+-------------------------+ The assigned :ref:`MeshLibrary`. .. _class_GridMap_property_theme: - :ref:`MeshLibrary` **theme** +----------+------------------+ | *Setter* | set_theme(value) | +----------+------------------+ | *Getter* | get_theme() | +----------+------------------+ Deprecated, use :ref:`mesh_library` instead. Method Descriptions ------------------- .. _class_GridMap_method_clear: - void **clear** **(** **)** Clear all cells. .. _class_GridMap_method_clear_baked_meshes: - void **clear_baked_meshes** **(** **)** .. _class_GridMap_method_get_bake_mesh_instance: - :ref:`RID` **get_bake_mesh_instance** **(** :ref:`int` idx **)** .. _class_GridMap_method_get_bake_meshes: - :ref:`Array` **get_bake_meshes** **(** **)** .. _class_GridMap_method_get_cell_item: - :ref:`int` **get_cell_item** **(** :ref:`int` x, :ref:`int` y, :ref:`int` z **)** const The :ref:`MeshLibrary` item index located at the grid-based X, Y and Z coordinates. If the cell is empty, :ref:`INVALID_CELL_ITEM` will be returned. .. _class_GridMap_method_get_cell_item_orientation: - :ref:`int` **get_cell_item_orientation** **(** :ref:`int` x, :ref:`int` y, :ref:`int` z **)** const The orientation of the cell at the grid-based X, Y and Z coordinates. -1 is returned if the cell is empty. .. _class_GridMap_method_get_collision_layer_bit: - :ref:`bool` **get_collision_layer_bit** **(** :ref:`int` bit **)** const .. _class_GridMap_method_get_collision_mask_bit: - :ref:`bool` **get_collision_mask_bit** **(** :ref:`int` bit **)** const .. _class_GridMap_method_get_meshes: - :ref:`Array` **get_meshes** **(** **)** Array of :ref:`Transform` and :ref:`Mesh` references corresponding to the non-empty cells in the grid. The transforms are specified in world space. .. _class_GridMap_method_get_used_cells: - :ref:`Array` **get_used_cells** **(** **)** const Array of :ref:`Vector3` with the non-empty cell coordinates in the grid map. .. _class_GridMap_method_make_baked_meshes: - void **make_baked_meshes** **(** :ref:`bool` gen_lightmap_uv=false, :ref:`float` lightmap_uv_texel_size=0.1 **)** .. _class_GridMap_method_map_to_world: - :ref:`Vector3` **map_to_world** **(** :ref:`int` x, :ref:`int` y, :ref:`int` z **)** const .. _class_GridMap_method_resource_changed: - void **resource_changed** **(** :ref:`Resource` resource **)** .. _class_GridMap_method_set_cell_item: - void **set_cell_item** **(** :ref:`int` x, :ref:`int` y, :ref:`int` z, :ref:`int` item, :ref:`int` orientation=0 **)** Set the mesh index for the cell referenced by its grid-based X, Y and Z coordinates. A negative item index will clear the cell. Optionally, the item's orientation can be passed. .. _class_GridMap_method_set_clip: - void **set_clip** **(** :ref:`bool` enabled, :ref:`bool` clipabove=true, :ref:`int` floor=0, Vector3.Axis axis=0 **)** .. _class_GridMap_method_set_collision_layer_bit: - void **set_collision_layer_bit** **(** :ref:`int` bit, :ref:`bool` value **)** .. _class_GridMap_method_set_collision_mask_bit: - void **set_collision_mask_bit** **(** :ref:`int` bit, :ref:`bool` value **)** .. _class_GridMap_method_world_to_map: - :ref:`Vector3` **world_to_map** **(** :ref:`Vector3` pos **)** const