123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 |
- :github_url: hide
- .. Generated automatically by doc/tools/make_rst.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/<name>/doc_classes.
- .. _class_GridMap:
- GridMap
- =======
- **Inherits:** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
- Node for 3D tile-based maps.
- Description
- -----------
- GridMap lets you place meshes on a grid interactively. It works both from the editor and from scripts, which can help you create in-game level editors.
- GridMaps use a :ref:`MeshLibrary<class_MeshLibrary>` which contains a list of tiles. Each tile is a mesh with materials plus optional collision and navigation shapes.
- A GridMap contains a collection of cells. Each grid cell refers to a tile in the :ref:`MeshLibrary<class_MeshLibrary>`. All cells in the map have the same dimensions.
- Internally, 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.
- **Note:** GridMap doesn't extend :ref:`VisualInstance<class_VisualInstance>` and therefore can't be hidden or cull masked based on :ref:`VisualInstance.layers<class_VisualInstance_property_layers>`. If you make a light not affect the first layer, the whole GridMap won't be lit by the light in question.
- Tutorials
- ---------
- - :doc:`../tutorials/3d/using_gridmaps`
- - `3D Platformer Demo <https://godotengine.org/asset-library/asset/125>`__
- - `3D Kinematic Character Demo <https://godotengine.org/asset-library/asset/126>`__
- Properties
- ----------
- +---------------------------------------+----------------------------------------------------------------------+------------------------+
- | :ref:`bool<class_bool>` | :ref:`cell_center_x<class_GridMap_property_cell_center_x>` | ``true`` |
- +---------------------------------------+----------------------------------------------------------------------+------------------------+
- | :ref:`bool<class_bool>` | :ref:`cell_center_y<class_GridMap_property_cell_center_y>` | ``true`` |
- +---------------------------------------+----------------------------------------------------------------------+------------------------+
- | :ref:`bool<class_bool>` | :ref:`cell_center_z<class_GridMap_property_cell_center_z>` | ``true`` |
- +---------------------------------------+----------------------------------------------------------------------+------------------------+
- | :ref:`int<class_int>` | :ref:`cell_octant_size<class_GridMap_property_cell_octant_size>` | ``8`` |
- +---------------------------------------+----------------------------------------------------------------------+------------------------+
- | :ref:`float<class_float>` | :ref:`cell_scale<class_GridMap_property_cell_scale>` | ``1.0`` |
- +---------------------------------------+----------------------------------------------------------------------+------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`cell_size<class_GridMap_property_cell_size>` | ``Vector3( 2, 2, 2 )`` |
- +---------------------------------------+----------------------------------------------------------------------+------------------------+
- | :ref:`int<class_int>` | :ref:`collision_layer<class_GridMap_property_collision_layer>` | ``1`` |
- +---------------------------------------+----------------------------------------------------------------------+------------------------+
- | :ref:`int<class_int>` | :ref:`collision_mask<class_GridMap_property_collision_mask>` | ``1`` |
- +---------------------------------------+----------------------------------------------------------------------+------------------------+
- | :ref:`MeshLibrary<class_MeshLibrary>` | :ref:`mesh_library<class_GridMap_property_mesh_library>` | |
- +---------------------------------------+----------------------------------------------------------------------+------------------------+
- | :ref:`bool<class_bool>` | :ref:`use_in_baked_light<class_GridMap_property_use_in_baked_light>` | ``false`` |
- +---------------------------------------+----------------------------------------------------------------------+------------------------+
- Methods
- -------
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`clear<class_GridMap_method_clear>` **(** **)** |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`clear_baked_meshes<class_GridMap_method_clear_baked_meshes>` **(** **)** |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`RID<class_RID>` | :ref:`get_bake_mesh_instance<class_GridMap_method_get_bake_mesh_instance>` **(** :ref:`int<class_int>` idx **)** |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Array<class_Array>` | :ref:`get_bake_meshes<class_GridMap_method_get_bake_meshes>` **(** **)** |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_cell_item<class_GridMap_method_get_cell_item>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** |const| |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_cell_item_orientation<class_GridMap_method_get_cell_item_orientation>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** |const| |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`get_collision_layer_bit<class_GridMap_method_get_collision_layer_bit>` **(** :ref:`int<class_int>` bit **)** |const| |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`get_collision_mask_bit<class_GridMap_method_get_collision_mask_bit>` **(** :ref:`int<class_int>` bit **)** |const| |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Array<class_Array>` | :ref:`get_meshes<class_GridMap_method_get_meshes>` **(** **)** |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Array<class_Array>` | :ref:`get_used_cells<class_GridMap_method_get_used_cells>` **(** **)** |const| |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`make_baked_meshes<class_GridMap_method_make_baked_meshes>` **(** :ref:`bool<class_bool>` gen_lightmap_uv=false, :ref:`float<class_float>` lightmap_uv_texel_size=0.1 **)** |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`map_to_world<class_GridMap_method_map_to_world>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** |const| |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`resource_changed<class_GridMap_method_resource_changed>` **(** :ref:`Resource<class_Resource>` resource **)** |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_cell_item<class_GridMap_method_set_cell_item>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z, :ref:`int<class_int>` item, :ref:`int<class_int>` orientation=0 **)** |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_clip<class_GridMap_method_set_clip>` **(** :ref:`bool<class_bool>` enabled, :ref:`bool<class_bool>` clipabove=true, :ref:`int<class_int>` floor=0, Vector3.Axis axis=0 **)** |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_collision_layer_bit<class_GridMap_method_set_collision_layer_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_collision_mask_bit<class_GridMap_method_set_collision_mask_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`world_to_map<class_GridMap_method_world_to_map>` **(** :ref:`Vector3<class_Vector3>` pos **)** |const| |
- +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- Signals
- -------
- .. _class_GridMap_signal_cell_size_changed:
- - **cell_size_changed** **(** :ref:`Vector3<class_Vector3>` cell_size **)**
- Emitted when :ref:`cell_size<class_GridMap_property_cell_size>` changes.
- Constants
- ---------
- .. _class_GridMap_constant_INVALID_CELL_ITEM:
- - **INVALID_CELL_ITEM** = **-1** --- Invalid cell item that can be used in :ref:`set_cell_item<class_GridMap_method_set_cell_item>` to clear cells (or represent an empty cell in :ref:`get_cell_item<class_GridMap_method_get_cell_item>`).
- Property Descriptions
- ---------------------
- .. _class_GridMap_property_cell_center_x:
- - :ref:`bool<class_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<class_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<class_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<class_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<class_float>` **cell_scale**
- +-----------+-----------------------+
- | *Default* | ``1.0`` |
- +-----------+-----------------------+
- | *Setter* | set_cell_scale(value) |
- +-----------+-----------------------+
- | *Getter* | get_cell_scale() |
- +-----------+-----------------------+
- The scale of the cell items.
- This does not affect the size of the grid cells themselves, only the items in them. This can be used to make cell items overlap their neighbors.
- ----
- .. _class_GridMap_property_cell_size:
- - :ref:`Vector3<class_Vector3>` **cell_size**
- +-----------+------------------------+
- | *Default* | ``Vector3( 2, 2, 2 )`` |
- +-----------+------------------------+
- | *Setter* | set_cell_size(value) |
- +-----------+------------------------+
- | *Getter* | get_cell_size() |
- +-----------+------------------------+
- The dimensions of the grid's cells.
- This does not affect the size of the meshes. See :ref:`cell_scale<class_GridMap_property_cell_scale>`.
- ----
- .. _class_GridMap_property_collision_layer:
- - :ref:`int<class_int>` **collision_layer**
- +-----------+----------------------------+
- | *Default* | ``1`` |
- +-----------+----------------------------+
- | *Setter* | set_collision_layer(value) |
- +-----------+----------------------------+
- | *Getter* | get_collision_layer() |
- +-----------+----------------------------+
- The physics layers this GridMap is in.
- GridMaps act as static bodies, meaning they aren't affected by gravity or other forces. They only affect other physics bodies that collide with them.
- ----
- .. _class_GridMap_property_collision_mask:
- - :ref:`int<class_int>` **collision_mask**
- +-----------+---------------------------+
- | *Default* | ``1`` |
- +-----------+---------------------------+
- | *Setter* | set_collision_mask(value) |
- +-----------+---------------------------+
- | *Getter* | get_collision_mask() |
- +-----------+---------------------------+
- The physics layers this GridMap detects collisions in. See `Collision layers and masks <https://docs.godotengine.org/en/3.4/tutorials/physics/physics_introduction.html#collision-layers-and-masks>`__ in the documentation for more information.
- ----
- .. _class_GridMap_property_mesh_library:
- - :ref:`MeshLibrary<class_MeshLibrary>` **mesh_library**
- +----------+-------------------------+
- | *Setter* | set_mesh_library(value) |
- +----------+-------------------------+
- | *Getter* | get_mesh_library() |
- +----------+-------------------------+
- The assigned :ref:`MeshLibrary<class_MeshLibrary>`.
- ----
- .. _class_GridMap_property_use_in_baked_light:
- - :ref:`bool<class_bool>` **use_in_baked_light**
- +-----------+-------------------------------+
- | *Default* | ``false`` |
- +-----------+-------------------------------+
- | *Setter* | set_use_in_baked_light(value) |
- +-----------+-------------------------------+
- | *Getter* | get_use_in_baked_light() |
- +-----------+-------------------------------+
- Controls whether this GridMap will be baked in a :ref:`BakedLightmap<class_BakedLightmap>` or not.
- 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<class_RID>` **get_bake_mesh_instance** **(** :ref:`int<class_int>` idx **)**
- ----
- .. _class_GridMap_method_get_bake_meshes:
- - :ref:`Array<class_Array>` **get_bake_meshes** **(** **)**
- Returns an array of :ref:`ArrayMesh<class_ArrayMesh>`\ es and :ref:`Transform<class_Transform>` references of all bake meshes that exist within the current GridMap.
- ----
- .. _class_GridMap_method_get_cell_item:
- - :ref:`int<class_int>` **get_cell_item** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** |const|
- The :ref:`MeshLibrary<class_MeshLibrary>` item index located at the grid-based X, Y and Z coordinates. If the cell is empty, :ref:`INVALID_CELL_ITEM<class_GridMap_constant_INVALID_CELL_ITEM>` will be returned.
- ----
- .. _class_GridMap_method_get_cell_item_orientation:
- - :ref:`int<class_int>` **get_cell_item_orientation** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_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<class_bool>` **get_collision_layer_bit** **(** :ref:`int<class_int>` bit **)** |const|
- Returns an individual bit on the :ref:`collision_layer<class_GridMap_property_collision_layer>`.
- ----
- .. _class_GridMap_method_get_collision_mask_bit:
- - :ref:`bool<class_bool>` **get_collision_mask_bit** **(** :ref:`int<class_int>` bit **)** |const|
- Returns an individual bit on the :ref:`collision_mask<class_GridMap_property_collision_mask>`.
- ----
- .. _class_GridMap_method_get_meshes:
- - :ref:`Array<class_Array>` **get_meshes** **(** **)**
- Returns an array of :ref:`Transform<class_Transform>` and :ref:`Mesh<class_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<class_Array>` **get_used_cells** **(** **)** |const|
- Returns an array of :ref:`Vector3<class_Vector3>` with the non-empty cell coordinates in the grid map.
- ----
- .. _class_GridMap_method_make_baked_meshes:
- - void **make_baked_meshes** **(** :ref:`bool<class_bool>` gen_lightmap_uv=false, :ref:`float<class_float>` lightmap_uv_texel_size=0.1 **)**
- ----
- .. _class_GridMap_method_map_to_world:
- - :ref:`Vector3<class_Vector3>` **map_to_world** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z **)** |const|
- Returns the position of a grid cell in the GridMap's local coordinate space.
- ----
- .. _class_GridMap_method_resource_changed:
- - void **resource_changed** **(** :ref:`Resource<class_Resource>` resource **)**
- ----
- .. _class_GridMap_method_set_cell_item:
- - void **set_cell_item** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` z, :ref:`int<class_int>` item, :ref:`int<class_int>` orientation=0 **)**
- Sets the mesh index for the cell referenced by its grid-based X, Y and Z coordinates.
- A negative item index such as :ref:`INVALID_CELL_ITEM<class_GridMap_constant_INVALID_CELL_ITEM>` will clear the cell.
- Optionally, the item's orientation can be passed. For valid orientation values, see :ref:`Basis.get_orthogonal_index<class_Basis_method_get_orthogonal_index>`.
- ----
- .. _class_GridMap_method_set_clip:
- - void **set_clip** **(** :ref:`bool<class_bool>` enabled, :ref:`bool<class_bool>` clipabove=true, :ref:`int<class_int>` floor=0, Vector3.Axis axis=0 **)**
- ----
- .. _class_GridMap_method_set_collision_layer_bit:
- - void **set_collision_layer_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
- Sets an individual bit on the :ref:`collision_layer<class_GridMap_property_collision_layer>`.
- ----
- .. _class_GridMap_method_set_collision_mask_bit:
- - void **set_collision_mask_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
- Sets an individual bit on the :ref:`collision_mask<class_GridMap_property_collision_mask>`.
- ----
- .. _class_GridMap_method_world_to_map:
- - :ref:`Vector3<class_Vector3>` **world_to_map** **(** :ref:`Vector3<class_Vector3>` pos **)** |const|
- Returns the coordinates of the grid cell containing the given point.
- ``pos`` should be in the GridMap's local coordinate space.
- .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
- .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
- .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|