class_tilemap.rst 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/TileMap.xml.
  6. .. _class_TileMap:
  7. TileMap
  8. =======
  9. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Node for 2D tile-based maps.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Node for 2D tile-based maps. Tilemaps use a :ref:`TileSet<class_TileSet>` which contain a list of tiles which are used to create grid-based maps. A TileMap may have several layers, layouting tiles on top of each other.
  15. .. rst-class:: classref-introduction-group
  16. Tutorials
  17. ---------
  18. - :doc:`Using Tilemaps <../tutorials/2d/using_tilemaps>`
  19. - `2D Platformer Demo <https://godotengine.org/asset-library/asset/120>`__
  20. - `2D Isometric Demo <https://godotengine.org/asset-library/asset/112>`__
  21. - `2D Hexagonal Demo <https://godotengine.org/asset-library/asset/111>`__
  22. - `2D Navigation Astar Demo <https://godotengine.org/asset-library/asset/519>`__
  23. - `2D Role Playing Game Demo <https://godotengine.org/asset-library/asset/520>`__
  24. - `2D Kinematic Character Demo <https://godotengine.org/asset-library/asset/113>`__
  25. .. rst-class:: classref-reftable-group
  26. Properties
  27. ----------
  28. .. table::
  29. :widths: auto
  30. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  31. | :ref:`int<class_int>` | :ref:`cell_quadrant_size<class_TileMap_property_cell_quadrant_size>` | ``16`` |
  32. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  33. | :ref:`bool<class_bool>` | :ref:`collision_animatable<class_TileMap_property_collision_animatable>` | ``false`` |
  34. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  35. | :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` | :ref:`collision_visibility_mode<class_TileMap_property_collision_visibility_mode>` | ``0`` |
  36. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  37. | :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` | :ref:`navigation_visibility_mode<class_TileMap_property_navigation_visibility_mode>` | ``0`` |
  38. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  39. | :ref:`TileSet<class_TileSet>` | :ref:`tile_set<class_TileMap_property_tile_set>` | |
  40. +----------------------------------------------------+--------------------------------------------------------------------------------------+-----------+
  41. .. rst-class:: classref-reftable-group
  42. Methods
  43. -------
  44. .. table::
  45. :widths: auto
  46. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`_tile_data_runtime_update<class_TileMap_method__tile_data_runtime_update>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`TileData<class_TileData>` tile_data **)** |virtual| |
  48. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`bool<class_bool>` | :ref:`_use_tile_data_runtime_update<class_TileMap_method__use_tile_data_runtime_update>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords **)** |virtual| |
  50. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`add_layer<class_TileMap_method_add_layer>` **(** :ref:`int<class_int>` to_position **)** |
  52. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`clear<class_TileMap_method_clear>` **(** **)** |
  54. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`clear_layer<class_TileMap_method_clear_layer>` **(** :ref:`int<class_int>` layer **)** |
  56. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`erase_cell<class_TileMap_method_erase_cell>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords **)** |
  58. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`fix_invalid_tiles<class_TileMap_method_fix_invalid_tiles>` **(** **)** |
  60. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`force_update<class_TileMap_method_force_update>` **(** :ref:`int<class_int>` layer=-1 **)** |
  62. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`int<class_int>` | :ref:`get_cell_alternative_tile<class_TileMap_method_get_cell_alternative_tile>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies=false **)** |const| |
  64. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`Vector2i<class_Vector2i>` | :ref:`get_cell_atlas_coords<class_TileMap_method_get_cell_atlas_coords>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies=false **)** |const| |
  66. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`int<class_int>` | :ref:`get_cell_source_id<class_TileMap_method_get_cell_source_id>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies=false **)** |const| |
  68. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`TileData<class_TileData>` | :ref:`get_cell_tile_data<class_TileMap_method_get_cell_tile_data>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies=false **)** |const| |
  70. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`Vector2i<class_Vector2i>` | :ref:`get_coords_for_body_rid<class_TileMap_method_get_coords_for_body_rid>` **(** :ref:`RID<class_RID>` body **)** |
  72. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`int<class_int>` | :ref:`get_layer_for_body_rid<class_TileMap_method_get_layer_for_body_rid>` **(** :ref:`RID<class_RID>` body **)** |
  74. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`Color<class_Color>` | :ref:`get_layer_modulate<class_TileMap_method_get_layer_modulate>` **(** :ref:`int<class_int>` layer **)** |const| |
  76. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`String<class_String>` | :ref:`get_layer_name<class_TileMap_method_get_layer_name>` **(** :ref:`int<class_int>` layer **)** |const| |
  78. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`RID<class_RID>` | :ref:`get_layer_navigation_map<class_TileMap_method_get_layer_navigation_map>` **(** :ref:`int<class_int>` layer **)** |const| |
  80. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`int<class_int>` | :ref:`get_layer_y_sort_origin<class_TileMap_method_get_layer_y_sort_origin>` **(** :ref:`int<class_int>` layer **)** |const| |
  82. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`int<class_int>` | :ref:`get_layer_z_index<class_TileMap_method_get_layer_z_index>` **(** :ref:`int<class_int>` layer **)** |const| |
  84. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`int<class_int>` | :ref:`get_layers_count<class_TileMap_method_get_layers_count>` **(** **)** |const| |
  86. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`RID<class_RID>` | :ref:`get_navigation_map<class_TileMap_method_get_navigation_map>` **(** :ref:`int<class_int>` layer **)** |const| |
  88. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | :ref:`Vector2i<class_Vector2i>` | :ref:`get_neighbor_cell<class_TileMap_method_get_neighbor_cell>` **(** :ref:`Vector2i<class_Vector2i>` coords, :ref:`CellNeighbor<enum_TileSet_CellNeighbor>` neighbor **)** |const| |
  90. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`TileMapPattern<class_TileMapPattern>` | :ref:`get_pattern<class_TileMap_method_get_pattern>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i[]<class_Vector2i>` coords_array **)** |
  92. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`Vector2i[]<class_Vector2i>` | :ref:`get_surrounding_cells<class_TileMap_method_get_surrounding_cells>` **(** :ref:`Vector2i<class_Vector2i>` coords **)** |
  94. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`Vector2i[]<class_Vector2i>` | :ref:`get_used_cells<class_TileMap_method_get_used_cells>` **(** :ref:`int<class_int>` layer **)** |const| |
  96. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`Vector2i[]<class_Vector2i>` | :ref:`get_used_cells_by_id<class_TileMap_method_get_used_cells_by_id>` **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` source_id=-1, :ref:`Vector2i<class_Vector2i>` atlas_coords=Vector2i(-1, -1), :ref:`int<class_int>` alternative_tile=-1 **)** |const| |
  98. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`Rect2i<class_Rect2i>` | :ref:`get_used_rect<class_TileMap_method_get_used_rect>` **(** **)** |const| |
  100. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`bool<class_bool>` | :ref:`is_layer_enabled<class_TileMap_method_is_layer_enabled>` **(** :ref:`int<class_int>` layer **)** |const| |
  102. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | :ref:`bool<class_bool>` | :ref:`is_layer_y_sort_enabled<class_TileMap_method_is_layer_y_sort_enabled>` **(** :ref:`int<class_int>` layer **)** |const| |
  104. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | :ref:`Vector2i<class_Vector2i>` | :ref:`local_to_map<class_TileMap_method_local_to_map>` **(** :ref:`Vector2<class_Vector2>` local_position **)** |const| |
  106. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | :ref:`Vector2i<class_Vector2i>` | :ref:`map_pattern<class_TileMap_method_map_pattern>` **(** :ref:`Vector2i<class_Vector2i>` position_in_tilemap, :ref:`Vector2i<class_Vector2i>` coords_in_pattern, :ref:`TileMapPattern<class_TileMapPattern>` pattern **)** |
  108. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | :ref:`Vector2<class_Vector2>` | :ref:`map_to_local<class_TileMap_method_map_to_local>` **(** :ref:`Vector2i<class_Vector2i>` map_position **)** |const| |
  110. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | void | :ref:`move_layer<class_TileMap_method_move_layer>` **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` to_position **)** |
  112. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | void | :ref:`remove_layer<class_TileMap_method_remove_layer>` **(** :ref:`int<class_int>` layer **)** |
  114. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | void | :ref:`set_cell<class_TileMap_method_set_cell>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`int<class_int>` source_id=-1, :ref:`Vector2i<class_Vector2i>` atlas_coords=Vector2i(-1, -1), :ref:`int<class_int>` alternative_tile=0 **)** |
  116. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | void | :ref:`set_cells_terrain_connect<class_TileMap_method_set_cells_terrain_connect>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i[]<class_Vector2i>` cells, :ref:`int<class_int>` terrain_set, :ref:`int<class_int>` terrain, :ref:`bool<class_bool>` ignore_empty_terrains=true **)** |
  118. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | void | :ref:`set_cells_terrain_path<class_TileMap_method_set_cells_terrain_path>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i[]<class_Vector2i>` path, :ref:`int<class_int>` terrain_set, :ref:`int<class_int>` terrain, :ref:`bool<class_bool>` ignore_empty_terrains=true **)** |
  120. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | void | :ref:`set_layer_enabled<class_TileMap_method_set_layer_enabled>` **(** :ref:`int<class_int>` layer, :ref:`bool<class_bool>` enabled **)** |
  122. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | void | :ref:`set_layer_modulate<class_TileMap_method_set_layer_modulate>` **(** :ref:`int<class_int>` layer, :ref:`Color<class_Color>` modulate **)** |
  124. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | void | :ref:`set_layer_name<class_TileMap_method_set_layer_name>` **(** :ref:`int<class_int>` layer, :ref:`String<class_String>` name **)** |
  126. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | void | :ref:`set_layer_navigation_map<class_TileMap_method_set_layer_navigation_map>` **(** :ref:`int<class_int>` layer, :ref:`RID<class_RID>` map **)** |
  128. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | void | :ref:`set_layer_y_sort_enabled<class_TileMap_method_set_layer_y_sort_enabled>` **(** :ref:`int<class_int>` layer, :ref:`bool<class_bool>` y_sort_enabled **)** |
  130. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. | void | :ref:`set_layer_y_sort_origin<class_TileMap_method_set_layer_y_sort_origin>` **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` y_sort_origin **)** |
  132. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  133. | void | :ref:`set_layer_z_index<class_TileMap_method_set_layer_z_index>` **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` z_index **)** |
  134. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  135. | void | :ref:`set_navigation_map<class_TileMap_method_set_navigation_map>` **(** :ref:`int<class_int>` layer, :ref:`RID<class_RID>` map **)** |
  136. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  137. | void | :ref:`set_pattern<class_TileMap_method_set_pattern>` **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` position, :ref:`TileMapPattern<class_TileMapPattern>` pattern **)** |
  138. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  139. .. rst-class:: classref-section-separator
  140. ----
  141. .. rst-class:: classref-descriptions-group
  142. Signals
  143. -------
  144. .. _class_TileMap_signal_changed:
  145. .. rst-class:: classref-signal
  146. **changed** **(** **)**
  147. Emitted when the :ref:`TileSet<class_TileSet>` of this TileMap changes.
  148. .. rst-class:: classref-section-separator
  149. ----
  150. .. rst-class:: classref-descriptions-group
  151. Enumerations
  152. ------------
  153. .. _enum_TileMap_VisibilityMode:
  154. .. rst-class:: classref-enumeration
  155. enum **VisibilityMode**:
  156. .. _class_TileMap_constant_VISIBILITY_MODE_DEFAULT:
  157. .. rst-class:: classref-enumeration-constant
  158. :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **VISIBILITY_MODE_DEFAULT** = ``0``
  159. Use the debug settings to determine visibility.
  160. .. _class_TileMap_constant_VISIBILITY_MODE_FORCE_HIDE:
  161. .. rst-class:: classref-enumeration-constant
  162. :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **VISIBILITY_MODE_FORCE_HIDE** = ``2``
  163. Always hide.
  164. .. _class_TileMap_constant_VISIBILITY_MODE_FORCE_SHOW:
  165. .. rst-class:: classref-enumeration-constant
  166. :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **VISIBILITY_MODE_FORCE_SHOW** = ``1``
  167. Always show.
  168. .. rst-class:: classref-section-separator
  169. ----
  170. .. rst-class:: classref-descriptions-group
  171. Property Descriptions
  172. ---------------------
  173. .. _class_TileMap_property_cell_quadrant_size:
  174. .. rst-class:: classref-property
  175. :ref:`int<class_int>` **cell_quadrant_size** = ``16``
  176. .. rst-class:: classref-property-setget
  177. - void **set_quadrant_size** **(** :ref:`int<class_int>` value **)**
  178. - :ref:`int<class_int>` **get_quadrant_size** **(** **)**
  179. The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size.
  180. .. rst-class:: classref-item-separator
  181. ----
  182. .. _class_TileMap_property_collision_animatable:
  183. .. rst-class:: classref-property
  184. :ref:`bool<class_bool>` **collision_animatable** = ``false``
  185. .. rst-class:: classref-property-setget
  186. - void **set_collision_animatable** **(** :ref:`bool<class_bool>` value **)**
  187. - :ref:`bool<class_bool>` **is_collision_animatable** **(** **)**
  188. If enabled, the TileMap will see its collisions synced to the physics tick and change its collision type from static to kinematic. This is required to create TileMap-based moving platform.
  189. \ **Note:** Enabling :ref:`collision_animatable<class_TileMap_property_collision_animatable>` may have a small performance impact, only do it if the TileMap is moving and has colliding tiles.
  190. .. rst-class:: classref-item-separator
  191. ----
  192. .. _class_TileMap_property_collision_visibility_mode:
  193. .. rst-class:: classref-property
  194. :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **collision_visibility_mode** = ``0``
  195. .. rst-class:: classref-property-setget
  196. - void **set_collision_visibility_mode** **(** :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` value **)**
  197. - :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **get_collision_visibility_mode** **(** **)**
  198. Show or hide the TileMap's collision shapes. If set to :ref:`VISIBILITY_MODE_DEFAULT<class_TileMap_constant_VISIBILITY_MODE_DEFAULT>`, this depends on the show collision debug settings.
  199. .. rst-class:: classref-item-separator
  200. ----
  201. .. _class_TileMap_property_navigation_visibility_mode:
  202. .. rst-class:: classref-property
  203. :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **navigation_visibility_mode** = ``0``
  204. .. rst-class:: classref-property-setget
  205. - void **set_navigation_visibility_mode** **(** :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` value **)**
  206. - :ref:`VisibilityMode<enum_TileMap_VisibilityMode>` **get_navigation_visibility_mode** **(** **)**
  207. Show or hide the TileMap's navigation meshes. If set to :ref:`VISIBILITY_MODE_DEFAULT<class_TileMap_constant_VISIBILITY_MODE_DEFAULT>`, this depends on the show navigation debug settings.
  208. .. rst-class:: classref-item-separator
  209. ----
  210. .. _class_TileMap_property_tile_set:
  211. .. rst-class:: classref-property
  212. :ref:`TileSet<class_TileSet>` **tile_set**
  213. .. rst-class:: classref-property-setget
  214. - void **set_tileset** **(** :ref:`TileSet<class_TileSet>` value **)**
  215. - :ref:`TileSet<class_TileSet>` **get_tileset** **(** **)**
  216. The assigned :ref:`TileSet<class_TileSet>`.
  217. .. rst-class:: classref-section-separator
  218. ----
  219. .. rst-class:: classref-descriptions-group
  220. Method Descriptions
  221. -------------------
  222. .. _class_TileMap_method__tile_data_runtime_update:
  223. .. rst-class:: classref-method
  224. void **_tile_data_runtime_update** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`TileData<class_TileData>` tile_data **)** |virtual|
  225. Called with a TileData object about to be used internally by the TileMap, allowing its modification at runtime.
  226. This method is only called if :ref:`_use_tile_data_runtime_update<class_TileMap_method__use_tile_data_runtime_update>` is implemented and returns ``true`` for the given tile ``coords`` and ``layer``.
  227. \ **Warning:** The ``tile_data`` object's sub-resources are the same as the one in the TileSet. Modifying them might impact the whole TileSet. Instead, make sure to duplicate those resources.
  228. \ **Note:** If the properties of ``tile_data`` object should change over time, use :ref:`force_update<class_TileMap_method_force_update>` to trigger a TileMap update.
  229. .. rst-class:: classref-item-separator
  230. ----
  231. .. _class_TileMap_method__use_tile_data_runtime_update:
  232. .. rst-class:: classref-method
  233. :ref:`bool<class_bool>` **_use_tile_data_runtime_update** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords **)** |virtual|
  234. Should return ``true`` if the tile at coordinates ``coords`` on layer ``layer`` requires a runtime update.
  235. \ **Warning:** Make sure this function only return ``true`` when needed. Any tile processed at runtime without a need for it will imply a significant performance penalty.
  236. .. rst-class:: classref-item-separator
  237. ----
  238. .. _class_TileMap_method_add_layer:
  239. .. rst-class:: classref-method
  240. void **add_layer** **(** :ref:`int<class_int>` to_position **)**
  241. Adds a layer at the given position ``to_position`` in the array. If ``to_position`` is negative, the position is counted from the end, with ``-1`` adding the layer at the end of the array.
  242. .. rst-class:: classref-item-separator
  243. ----
  244. .. _class_TileMap_method_clear:
  245. .. rst-class:: classref-method
  246. void **clear** **(** **)**
  247. Clears all cells.
  248. .. rst-class:: classref-item-separator
  249. ----
  250. .. _class_TileMap_method_clear_layer:
  251. .. rst-class:: classref-method
  252. void **clear_layer** **(** :ref:`int<class_int>` layer **)**
  253. Clears all cells on the given layer.
  254. If ``layer`` is negative, the layers are accessed from the last one.
  255. .. rst-class:: classref-item-separator
  256. ----
  257. .. _class_TileMap_method_erase_cell:
  258. .. rst-class:: classref-method
  259. void **erase_cell** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords **)**
  260. Erases the cell on layer ``layer`` at coordinates ``coords``.
  261. If ``layer`` is negative, the layers are accessed from the last one.
  262. .. rst-class:: classref-item-separator
  263. ----
  264. .. _class_TileMap_method_fix_invalid_tiles:
  265. .. rst-class:: classref-method
  266. void **fix_invalid_tiles** **(** **)**
  267. Clears cells that do not exist in the tileset.
  268. .. rst-class:: classref-item-separator
  269. ----
  270. .. _class_TileMap_method_force_update:
  271. .. rst-class:: classref-method
  272. void **force_update** **(** :ref:`int<class_int>` layer=-1 **)**
  273. Triggers an update of the TileMap. If ``layer`` is provided and is positive, only updates the given layer.
  274. \ **Note:** The TileMap node updates automatically when one of its properties is modified. A manual update is only needed if runtime modifications (implemented in :ref:`_tile_data_runtime_update<class_TileMap_method__tile_data_runtime_update>`) need to be applied.
  275. \ **Warning:** Updating the TileMap is computationally expensive and may impact performance. Try to limit the number of updates and the tiles they impact (by placing frequently updated tiles in a dedicated layer for example).
  276. .. rst-class:: classref-item-separator
  277. ----
  278. .. _class_TileMap_method_get_cell_alternative_tile:
  279. .. rst-class:: classref-method
  280. :ref:`int<class_int>` **get_cell_alternative_tile** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies=false **)** |const|
  281. Returns the tile alternative ID of the cell on layer ``layer`` at ``coords``. If ``use_proxies`` is ``false``, ignores the :ref:`TileSet<class_TileSet>`'s tile proxies, returning the raw alternative identifier. See :ref:`TileSet.map_tile_proxy<class_TileSet_method_map_tile_proxy>`.
  282. If ``layer`` is negative, the layers are accessed from the last one.
  283. .. rst-class:: classref-item-separator
  284. ----
  285. .. _class_TileMap_method_get_cell_atlas_coords:
  286. .. rst-class:: classref-method
  287. :ref:`Vector2i<class_Vector2i>` **get_cell_atlas_coords** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies=false **)** |const|
  288. Returns the tile atlas coordinates ID of the cell on layer ``layer`` at coordinates ``coords``. If ``use_proxies`` is ``false``, ignores the :ref:`TileSet<class_TileSet>`'s tile proxies, returning the raw alternative identifier. See :ref:`TileSet.map_tile_proxy<class_TileSet_method_map_tile_proxy>`.
  289. If ``layer`` is negative, the layers are accessed from the last one.
  290. .. rst-class:: classref-item-separator
  291. ----
  292. .. _class_TileMap_method_get_cell_source_id:
  293. .. rst-class:: classref-method
  294. :ref:`int<class_int>` **get_cell_source_id** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies=false **)** |const|
  295. Returns the tile source ID of the cell on layer ``layer`` at coordinates ``coords``. Returns ``-1`` if the cell does not exist.
  296. If ``use_proxies`` is ``false``, ignores the :ref:`TileSet<class_TileSet>`'s tile proxies, returning the raw alternative identifier. See :ref:`TileSet.map_tile_proxy<class_TileSet_method_map_tile_proxy>`.
  297. If ``layer`` is negative, the layers are accessed from the last one.
  298. .. rst-class:: classref-item-separator
  299. ----
  300. .. _class_TileMap_method_get_cell_tile_data:
  301. .. rst-class:: classref-method
  302. :ref:`TileData<class_TileData>` **get_cell_tile_data** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`bool<class_bool>` use_proxies=false **)** |const|
  303. Returns the :ref:`TileData<class_TileData>` object associated with the given cell, or ``null`` if the cell does not exist or is not a :ref:`TileSetAtlasSource<class_TileSetAtlasSource>`.
  304. If ``layer`` is negative, the layers are accessed from the last one.
  305. If ``use_proxies`` is ``false``, ignores the :ref:`TileSet<class_TileSet>`'s tile proxies, returning the raw alternative identifier. See :ref:`TileSet.map_tile_proxy<class_TileSet_method_map_tile_proxy>`.
  306. ::
  307. func get_clicked_tile_power():
  308. var clicked_cell = tile_map.local_to_map(tile_map.get_local_mouse_position())
  309. var data = tile_map.get_cell_tile_data(0, clicked_cell)
  310. if data:
  311. return data.get_custom_data("power")
  312. else:
  313. return 0
  314. .. rst-class:: classref-item-separator
  315. ----
  316. .. _class_TileMap_method_get_coords_for_body_rid:
  317. .. rst-class:: classref-method
  318. :ref:`Vector2i<class_Vector2i>` **get_coords_for_body_rid** **(** :ref:`RID<class_RID>` body **)**
  319. Returns the coordinates of the tile for given physics body RID. Such RID can be retrieved from :ref:`KinematicCollision2D.get_collider_rid<class_KinematicCollision2D_method_get_collider_rid>`, when colliding with a tile.
  320. .. rst-class:: classref-item-separator
  321. ----
  322. .. _class_TileMap_method_get_layer_for_body_rid:
  323. .. rst-class:: classref-method
  324. :ref:`int<class_int>` **get_layer_for_body_rid** **(** :ref:`RID<class_RID>` body **)**
  325. Returns the tilemap layer of the tile for given physics body RID. Such RID can be retrieved from :ref:`KinematicCollision2D.get_collider_rid<class_KinematicCollision2D_method_get_collider_rid>`, when colliding with a tile.
  326. .. rst-class:: classref-item-separator
  327. ----
  328. .. _class_TileMap_method_get_layer_modulate:
  329. .. rst-class:: classref-method
  330. :ref:`Color<class_Color>` **get_layer_modulate** **(** :ref:`int<class_int>` layer **)** |const|
  331. Returns a TileMap layer's modulate.
  332. If ``layer`` is negative, the layers are accessed from the last one.
  333. .. rst-class:: classref-item-separator
  334. ----
  335. .. _class_TileMap_method_get_layer_name:
  336. .. rst-class:: classref-method
  337. :ref:`String<class_String>` **get_layer_name** **(** :ref:`int<class_int>` layer **)** |const|
  338. Returns a TileMap layer's name.
  339. If ``layer`` is negative, the layers are accessed from the last one.
  340. .. rst-class:: classref-item-separator
  341. ----
  342. .. _class_TileMap_method_get_layer_navigation_map:
  343. .. rst-class:: classref-method
  344. :ref:`RID<class_RID>` **get_layer_navigation_map** **(** :ref:`int<class_int>` layer **)** |const|
  345. Returns the :ref:`NavigationServer2D<class_NavigationServer2D>` navigation map :ref:`RID<class_RID>` currently assigned to the specified TileMap ``layer``.
  346. By default the TileMap uses the default :ref:`World2D<class_World2D>` navigation map for the first TileMap layer. For each additional TileMap layer a new navigation map is created for the additional layer.
  347. In order to make :ref:`NavigationAgent2D<class_NavigationAgent2D>` switch between TileMap layer navigation maps use :ref:`NavigationAgent2D.set_navigation_map<class_NavigationAgent2D_method_set_navigation_map>` with the navigation map received from :ref:`get_layer_navigation_map<class_TileMap_method_get_layer_navigation_map>`.
  348. If ``layer`` is negative, the layers are accessed from the last one.
  349. .. rst-class:: classref-item-separator
  350. ----
  351. .. _class_TileMap_method_get_layer_y_sort_origin:
  352. .. rst-class:: classref-method
  353. :ref:`int<class_int>` **get_layer_y_sort_origin** **(** :ref:`int<class_int>` layer **)** |const|
  354. Returns a TileMap layer's Y sort origin.
  355. If ``layer`` is negative, the layers are accessed from the last one.
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_TileMap_method_get_layer_z_index:
  359. .. rst-class:: classref-method
  360. :ref:`int<class_int>` **get_layer_z_index** **(** :ref:`int<class_int>` layer **)** |const|
  361. Returns a TileMap layer's Z-index value.
  362. If ``layer`` is negative, the layers are accessed from the last one.
  363. .. rst-class:: classref-item-separator
  364. ----
  365. .. _class_TileMap_method_get_layers_count:
  366. .. rst-class:: classref-method
  367. :ref:`int<class_int>` **get_layers_count** **(** **)** |const|
  368. Returns the number of layers in the TileMap.
  369. .. rst-class:: classref-item-separator
  370. ----
  371. .. _class_TileMap_method_get_navigation_map:
  372. .. rst-class:: classref-method
  373. :ref:`RID<class_RID>` **get_navigation_map** **(** :ref:`int<class_int>` layer **)** |const|
  374. See :ref:`get_layer_navigation_map<class_TileMap_method_get_layer_navigation_map>`.
  375. .. rst-class:: classref-item-separator
  376. ----
  377. .. _class_TileMap_method_get_neighbor_cell:
  378. .. rst-class:: classref-method
  379. :ref:`Vector2i<class_Vector2i>` **get_neighbor_cell** **(** :ref:`Vector2i<class_Vector2i>` coords, :ref:`CellNeighbor<enum_TileSet_CellNeighbor>` neighbor **)** |const|
  380. Returns the neighboring cell to the one at coordinates ``coords``, identified by the ``neighbor`` direction. This method takes into account the different layouts a TileMap can take.
  381. .. rst-class:: classref-item-separator
  382. ----
  383. .. _class_TileMap_method_get_pattern:
  384. .. rst-class:: classref-method
  385. :ref:`TileMapPattern<class_TileMapPattern>` **get_pattern** **(** :ref:`int<class_int>` layer, :ref:`Vector2i[]<class_Vector2i>` coords_array **)**
  386. Creates a new :ref:`TileMapPattern<class_TileMapPattern>` from the given layer and set of cells.
  387. If ``layer`` is negative, the layers are accessed from the last one.
  388. .. rst-class:: classref-item-separator
  389. ----
  390. .. _class_TileMap_method_get_surrounding_cells:
  391. .. rst-class:: classref-method
  392. :ref:`Vector2i[]<class_Vector2i>` **get_surrounding_cells** **(** :ref:`Vector2i<class_Vector2i>` coords **)**
  393. Returns the list of all neighbourings cells to the one at ``coords``.
  394. .. rst-class:: classref-item-separator
  395. ----
  396. .. _class_TileMap_method_get_used_cells:
  397. .. rst-class:: classref-method
  398. :ref:`Vector2i[]<class_Vector2i>` **get_used_cells** **(** :ref:`int<class_int>` layer **)** |const|
  399. Returns a :ref:`Vector2i<class_Vector2i>` array with the positions of all cells containing a tile in the given layer. A cell is considered empty if its source identifier equals -1, its atlas coordinates identifiers is ``Vector2(-1, -1)`` and its alternative identifier is -1.
  400. If ``layer`` is negative, the layers are accessed from the last one.
  401. .. rst-class:: classref-item-separator
  402. ----
  403. .. _class_TileMap_method_get_used_cells_by_id:
  404. .. rst-class:: classref-method
  405. :ref:`Vector2i[]<class_Vector2i>` **get_used_cells_by_id** **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` source_id=-1, :ref:`Vector2i<class_Vector2i>` atlas_coords=Vector2i(-1, -1), :ref:`int<class_int>` alternative_tile=-1 **)** |const|
  406. Returns a :ref:`Vector2i<class_Vector2i>` array with the positions of all cells containing a tile in the given layer. Tiles may be filtered according to their source (``source_id``), their atlas coordinates (``atlas_coords``) or alternative id (``alternative_tile``).
  407. If a parameter has its value set to the default one, this parameter is not used to filter a cell. Thus, if all parameters have their respective default value, this method returns the same result as :ref:`get_used_cells<class_TileMap_method_get_used_cells>`.
  408. A cell is considered empty if its source identifier equals -1, its atlas coordinates identifiers is ``Vector2(-1, -1)`` and its alternative identifier is -1.
  409. If ``layer`` is negative, the layers are accessed from the last one.
  410. .. rst-class:: classref-item-separator
  411. ----
  412. .. _class_TileMap_method_get_used_rect:
  413. .. rst-class:: classref-method
  414. :ref:`Rect2i<class_Rect2i>` **get_used_rect** **(** **)** |const|
  415. Returns a rectangle enclosing the used (non-empty) tiles of the map, including all layers.
  416. .. rst-class:: classref-item-separator
  417. ----
  418. .. _class_TileMap_method_is_layer_enabled:
  419. .. rst-class:: classref-method
  420. :ref:`bool<class_bool>` **is_layer_enabled** **(** :ref:`int<class_int>` layer **)** |const|
  421. Returns if a layer is enabled.
  422. If ``layer`` is negative, the layers are accessed from the last one.
  423. .. rst-class:: classref-item-separator
  424. ----
  425. .. _class_TileMap_method_is_layer_y_sort_enabled:
  426. .. rst-class:: classref-method
  427. :ref:`bool<class_bool>` **is_layer_y_sort_enabled** **(** :ref:`int<class_int>` layer **)** |const|
  428. Returns if a layer Y-sorts its tiles.
  429. If ``layer`` is negative, the layers are accessed from the last one.
  430. .. rst-class:: classref-item-separator
  431. ----
  432. .. _class_TileMap_method_local_to_map:
  433. .. rst-class:: classref-method
  434. :ref:`Vector2i<class_Vector2i>` **local_to_map** **(** :ref:`Vector2<class_Vector2>` local_position **)** |const|
  435. Returns the map coordinates of the cell containing the given ``local_position``. If ``local_position`` is in global coordinates, consider using :ref:`Node2D.to_local<class_Node2D_method_to_local>` before passing it to this method. See also :ref:`map_to_local<class_TileMap_method_map_to_local>`.
  436. .. rst-class:: classref-item-separator
  437. ----
  438. .. _class_TileMap_method_map_pattern:
  439. .. rst-class:: classref-method
  440. :ref:`Vector2i<class_Vector2i>` **map_pattern** **(** :ref:`Vector2i<class_Vector2i>` position_in_tilemap, :ref:`Vector2i<class_Vector2i>` coords_in_pattern, :ref:`TileMapPattern<class_TileMapPattern>` pattern **)**
  441. Returns for the given coordinate ``coords_in_pattern`` in a :ref:`TileMapPattern<class_TileMapPattern>` the corresponding cell coordinates if the pattern was pasted at the ``position_in_tilemap`` coordinates (see :ref:`set_pattern<class_TileMap_method_set_pattern>`). This mapping is required as in half-offset tile shapes, the mapping might not work by calculating ``position_in_tile_map + coords_in_pattern``.
  442. .. rst-class:: classref-item-separator
  443. ----
  444. .. _class_TileMap_method_map_to_local:
  445. .. rst-class:: classref-method
  446. :ref:`Vector2<class_Vector2>` **map_to_local** **(** :ref:`Vector2i<class_Vector2i>` map_position **)** |const|
  447. Returns the centered position of a cell in the TileMap's local coordinate space. To convert the returned value into global coordinates, use :ref:`Node2D.to_global<class_Node2D_method_to_global>`. See also :ref:`local_to_map<class_TileMap_method_local_to_map>`.
  448. \ **Note:** This may not correspond to the visual position of the tile, i.e. it ignores the :ref:`TileData.texture_origin<class_TileData_property_texture_origin>` property of individual tiles.
  449. .. rst-class:: classref-item-separator
  450. ----
  451. .. _class_TileMap_method_move_layer:
  452. .. rst-class:: classref-method
  453. void **move_layer** **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` to_position **)**
  454. Moves the layer at index ``layer`` to the given position ``to_position`` in the array.
  455. .. rst-class:: classref-item-separator
  456. ----
  457. .. _class_TileMap_method_remove_layer:
  458. .. rst-class:: classref-method
  459. void **remove_layer** **(** :ref:`int<class_int>` layer **)**
  460. Removes the layer at index ``layer``.
  461. .. rst-class:: classref-item-separator
  462. ----
  463. .. _class_TileMap_method_set_cell:
  464. .. rst-class:: classref-method
  465. void **set_cell** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` coords, :ref:`int<class_int>` source_id=-1, :ref:`Vector2i<class_Vector2i>` atlas_coords=Vector2i(-1, -1), :ref:`int<class_int>` alternative_tile=0 **)**
  466. Sets the tile identifiers for the cell on layer ``layer`` at coordinates ``coords``. Each tile of the :ref:`TileSet<class_TileSet>` is identified using three parts:
  467. - The source identifier ``source_id`` identifies a :ref:`TileSetSource<class_TileSetSource>` identifier. See :ref:`TileSet.set_source_id<class_TileSet_method_set_source_id>`,
  468. - The atlas coordinates identifier ``atlas_coords`` identifies a tile coordinates in the atlas (if the source is a :ref:`TileSetAtlasSource<class_TileSetAtlasSource>`). For :ref:`TileSetScenesCollectionSource<class_TileSetScenesCollectionSource>` it should always be ``Vector2i(0, 0)``),
  469. - The alternative tile identifier ``alternative_tile`` identifies a tile alternative in the atlas (if the source is a :ref:`TileSetAtlasSource<class_TileSetAtlasSource>`), and the scene for a :ref:`TileSetScenesCollectionSource<class_TileSetScenesCollectionSource>`.
  470. If ``source_id`` is set to ``-1``, ``atlas_coords`` to ``Vector2i(-1, -1)`` or ``alternative_tile`` to ``-1``, the cell will be erased. An erased cell gets **all** its identifiers automatically set to their respective invalid values, namely ``-1``, ``Vector2i(-1, -1)`` and ``-1``.
  471. If ``layer`` is negative, the layers are accessed from the last one.
  472. .. rst-class:: classref-item-separator
  473. ----
  474. .. _class_TileMap_method_set_cells_terrain_connect:
  475. .. rst-class:: classref-method
  476. void **set_cells_terrain_connect** **(** :ref:`int<class_int>` layer, :ref:`Vector2i[]<class_Vector2i>` cells, :ref:`int<class_int>` terrain_set, :ref:`int<class_int>` terrain, :ref:`bool<class_bool>` ignore_empty_terrains=true **)**
  477. Update all the cells in the ``cells`` coordinates array so that they use the given ``terrain`` for the given ``terrain_set``. If an updated cell has the same terrain as one of its neighboring cells, this function tries to join the two. This function might update neighboring tiles if needed to create correct terrain transitions.
  478. If ``ignore_empty_terrains`` is true, empty terrains will be ignored when trying to find the best fitting tile for the given terrain constraints.
  479. If ``layer`` is negative, the layers are accessed from the last one.
  480. \ **Note:** To work correctly, this method requires the TileMap's TileSet to have terrains set up with all required terrain combinations. Otherwise, it may produce unexpected results.
  481. .. rst-class:: classref-item-separator
  482. ----
  483. .. _class_TileMap_method_set_cells_terrain_path:
  484. .. rst-class:: classref-method
  485. void **set_cells_terrain_path** **(** :ref:`int<class_int>` layer, :ref:`Vector2i[]<class_Vector2i>` path, :ref:`int<class_int>` terrain_set, :ref:`int<class_int>` terrain, :ref:`bool<class_bool>` ignore_empty_terrains=true **)**
  486. Update all the cells in the ``path`` coordinates array so that they use the given ``terrain`` for the given ``terrain_set``. The function will also connect two successive cell in the path with the same terrain. This function might update neighboring tiles if needed to create correct terrain transitions.
  487. If ``ignore_empty_terrains`` is true, empty terrains will be ignored when trying to find the best fitting tile for the given terrain constraints.
  488. If ``layer`` is negative, the layers are accessed from the last one.
  489. \ **Note:** To work correctly, this method requires the TileMap's TileSet to have terrains set up with all required terrain combinations. Otherwise, it may produce unexpected results.
  490. .. rst-class:: classref-item-separator
  491. ----
  492. .. _class_TileMap_method_set_layer_enabled:
  493. .. rst-class:: classref-method
  494. void **set_layer_enabled** **(** :ref:`int<class_int>` layer, :ref:`bool<class_bool>` enabled **)**
  495. Enables or disables the layer ``layer``. A disabled layer is not processed at all (no rendering, no physics, etc...).
  496. If ``layer`` is negative, the layers are accessed from the last one.
  497. .. rst-class:: classref-item-separator
  498. ----
  499. .. _class_TileMap_method_set_layer_modulate:
  500. .. rst-class:: classref-method
  501. void **set_layer_modulate** **(** :ref:`int<class_int>` layer, :ref:`Color<class_Color>` modulate **)**
  502. Sets a layer's color. It will be multiplied by tile's color and TileMap's modulate.
  503. If ``layer`` is negative, the layers are accessed from the last one.
  504. .. rst-class:: classref-item-separator
  505. ----
  506. .. _class_TileMap_method_set_layer_name:
  507. .. rst-class:: classref-method
  508. void **set_layer_name** **(** :ref:`int<class_int>` layer, :ref:`String<class_String>` name **)**
  509. Sets a layer's name. This is mostly useful in the editor.
  510. If ``layer`` is negative, the layers are accessed from the last one.
  511. .. rst-class:: classref-item-separator
  512. ----
  513. .. _class_TileMap_method_set_layer_navigation_map:
  514. .. rst-class:: classref-method
  515. void **set_layer_navigation_map** **(** :ref:`int<class_int>` layer, :ref:`RID<class_RID>` map **)**
  516. Assigns a :ref:`NavigationServer2D<class_NavigationServer2D>` navigation map :ref:`RID<class_RID>` to the specified TileMap ``layer``.
  517. By default the TileMap uses the default :ref:`World2D<class_World2D>` navigation map for the first TileMap layer. For each additional TileMap layer a new navigation map is created for the additional layer.
  518. In order to make :ref:`NavigationAgent2D<class_NavigationAgent2D>` switch between TileMap layer navigation maps use :ref:`NavigationAgent2D.set_navigation_map<class_NavigationAgent2D_method_set_navigation_map>` with the navigation map received from :ref:`get_layer_navigation_map<class_TileMap_method_get_layer_navigation_map>`.
  519. If ``layer`` is negative, the layers are accessed from the last one.
  520. .. rst-class:: classref-item-separator
  521. ----
  522. .. _class_TileMap_method_set_layer_y_sort_enabled:
  523. .. rst-class:: classref-method
  524. void **set_layer_y_sort_enabled** **(** :ref:`int<class_int>` layer, :ref:`bool<class_bool>` y_sort_enabled **)**
  525. Enables or disables a layer's Y-sorting. If a layer is Y-sorted, the layer will behave as a CanvasItem node where each of its tile gets Y-sorted.
  526. Y-sorted layers should usually be on different Z-index values than not Y-sorted layers, otherwise, each of those layer will be Y-sorted as whole with the Y-sorted one. This is usually an undesired behavior.
  527. If ``layer`` is negative, the layers are accessed from the last one.
  528. .. rst-class:: classref-item-separator
  529. ----
  530. .. _class_TileMap_method_set_layer_y_sort_origin:
  531. .. rst-class:: classref-method
  532. void **set_layer_y_sort_origin** **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` y_sort_origin **)**
  533. Sets a layer's Y-sort origin value. This Y-sort origin value is added to each tile's Y-sort origin value.
  534. This allows, for example, to fake a different height level on each layer. This can be useful for top-down view games.
  535. If ``layer`` is negative, the layers are accessed from the last one.
  536. .. rst-class:: classref-item-separator
  537. ----
  538. .. _class_TileMap_method_set_layer_z_index:
  539. .. rst-class:: classref-method
  540. void **set_layer_z_index** **(** :ref:`int<class_int>` layer, :ref:`int<class_int>` z_index **)**
  541. Sets a layers Z-index value. This Z-index is added to each tile's Z-index value.
  542. If ``layer`` is negative, the layers are accessed from the last one.
  543. .. rst-class:: classref-item-separator
  544. ----
  545. .. _class_TileMap_method_set_navigation_map:
  546. .. rst-class:: classref-method
  547. void **set_navigation_map** **(** :ref:`int<class_int>` layer, :ref:`RID<class_RID>` map **)**
  548. See :ref:`set_layer_navigation_map<class_TileMap_method_set_layer_navigation_map>`.
  549. .. rst-class:: classref-item-separator
  550. ----
  551. .. _class_TileMap_method_set_pattern:
  552. .. rst-class:: classref-method
  553. void **set_pattern** **(** :ref:`int<class_int>` layer, :ref:`Vector2i<class_Vector2i>` position, :ref:`TileMapPattern<class_TileMapPattern>` pattern **)**
  554. Paste the given :ref:`TileMapPattern<class_TileMapPattern>` at the given ``position`` and ``layer`` in the tile map.
  555. If ``layer`` is negative, the layers are accessed from the last one.
  556. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  557. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  558. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  559. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  560. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  561. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  562. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`