GridMap.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="GridMap" inherits="Node3D" keywords="tilemap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
  3. <brief_description>
  4. Node for 3D tile-based maps.
  5. </brief_description>
  6. <description>
  7. 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.
  8. GridMaps use a [MeshLibrary] which contains a list of tiles. Each tile is a mesh with materials plus optional collision and navigation shapes.
  9. A GridMap contains a collection of cells. Each grid cell refers to a tile in the [MeshLibrary]. All cells in the map have the same dimensions.
  10. 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.
  11. [b]Note:[/b] GridMap doesn't extend [VisualInstance3D] and therefore can't be hidden or cull masked based on [member VisualInstance3D.layers]. If you make a light not affect the first layer, the whole GridMap won't be lit by the light in question.
  12. </description>
  13. <tutorials>
  14. <link title="Using gridmaps">$DOCS_URL/tutorials/3d/using_gridmaps.html</link>
  15. <link title="3D Platformer Demo">https://godotengine.org/asset-library/asset/2748</link>
  16. <link title="3D Kinematic Character Demo">https://godotengine.org/asset-library/asset/2739</link>
  17. </tutorials>
  18. <methods>
  19. <method name="clear">
  20. <return type="void" />
  21. <description>
  22. Clear all cells.
  23. </description>
  24. </method>
  25. <method name="clear_baked_meshes">
  26. <return type="void" />
  27. <description>
  28. Clears all baked meshes. See [method make_baked_meshes].
  29. </description>
  30. </method>
  31. <method name="get_bake_mesh_instance">
  32. <return type="RID" />
  33. <param index="0" name="idx" type="int" />
  34. <description>
  35. Returns [RID] of a baked mesh with the given [param idx].
  36. </description>
  37. </method>
  38. <method name="get_bake_meshes">
  39. <return type="Array" />
  40. <description>
  41. Returns an array of [ArrayMesh]es and [Transform3D] references of all bake meshes that exist within the current GridMap.
  42. </description>
  43. </method>
  44. <method name="get_basis_with_orthogonal_index" qualifiers="const">
  45. <return type="Basis" />
  46. <param index="0" name="index" type="int" />
  47. <description>
  48. Returns one of 24 possible rotations that lie along the vectors (x,y,z) with each component being either -1, 0, or 1. For further details, refer to the Godot source code.
  49. </description>
  50. </method>
  51. <method name="get_cell_item" qualifiers="const">
  52. <return type="int" />
  53. <param index="0" name="position" type="Vector3i" />
  54. <description>
  55. The [MeshLibrary] item index located at the given grid coordinates. If the cell is empty, [constant INVALID_CELL_ITEM] will be returned.
  56. </description>
  57. </method>
  58. <method name="get_cell_item_basis" qualifiers="const">
  59. <return type="Basis" />
  60. <param index="0" name="position" type="Vector3i" />
  61. <description>
  62. Returns the basis that gives the specified cell its orientation.
  63. </description>
  64. </method>
  65. <method name="get_cell_item_orientation" qualifiers="const">
  66. <return type="int" />
  67. <param index="0" name="position" type="Vector3i" />
  68. <description>
  69. The orientation of the cell at the given grid coordinates. [code]-1[/code] is returned if the cell is empty.
  70. </description>
  71. </method>
  72. <method name="get_collision_layer_value" qualifiers="const">
  73. <return type="bool" />
  74. <param index="0" name="layer_number" type="int" />
  75. <description>
  76. Returns whether or not the specified layer of the [member collision_layer] is enabled, given a [param layer_number] between 1 and 32.
  77. </description>
  78. </method>
  79. <method name="get_collision_mask_value" qualifiers="const">
  80. <return type="bool" />
  81. <param index="0" name="layer_number" type="int" />
  82. <description>
  83. Returns whether or not the specified layer of the [member collision_mask] is enabled, given a [param layer_number] between 1 and 32.
  84. </description>
  85. </method>
  86. <method name="get_meshes" qualifiers="const">
  87. <return type="Array" />
  88. <description>
  89. Returns an array of [Transform3D] and [Mesh] references corresponding to the non-empty cells in the grid. The transforms are specified in local space.
  90. </description>
  91. </method>
  92. <method name="get_navigation_map" qualifiers="const">
  93. <return type="RID" />
  94. <description>
  95. Returns the [RID] of the navigation map this GridMap node uses for its cell baked navigation meshes.
  96. This function returns always the map set on the GridMap node and not the map on the NavigationServer. If the map is changed directly with the NavigationServer API the GridMap node will not be aware of the map change.
  97. </description>
  98. </method>
  99. <method name="get_orthogonal_index_from_basis" qualifiers="const">
  100. <return type="int" />
  101. <param index="0" name="basis" type="Basis" />
  102. <description>
  103. This function considers a discretization of rotations into 24 points on unit sphere, lying along the vectors (x,y,z) with each component being either -1, 0, or 1, and returns the index (in the range from 0 to 23) of the point best representing the orientation of the object. For further details, refer to the Godot source code.
  104. </description>
  105. </method>
  106. <method name="get_used_cells" qualifiers="const">
  107. <return type="Vector3i[]" />
  108. <description>
  109. Returns an array of [Vector3] with the non-empty cell coordinates in the grid map.
  110. </description>
  111. </method>
  112. <method name="get_used_cells_by_item" qualifiers="const">
  113. <return type="Vector3i[]" />
  114. <param index="0" name="item" type="int" />
  115. <description>
  116. Returns an array of all cells with the given item index specified in [param item].
  117. </description>
  118. </method>
  119. <method name="local_to_map" qualifiers="const">
  120. <return type="Vector3i" />
  121. <param index="0" name="local_position" type="Vector3" />
  122. <description>
  123. Returns the map coordinates of the cell containing the given [param local_position]. If [param local_position] is in global coordinates, consider using [method Node3D.to_local] before passing it to this method. See also [method map_to_local].
  124. </description>
  125. </method>
  126. <method name="make_baked_meshes">
  127. <return type="void" />
  128. <param index="0" name="gen_lightmap_uv" type="bool" default="false" />
  129. <param index="1" name="lightmap_uv_texel_size" type="float" default="0.1" />
  130. <description>
  131. Bakes lightmap data for all meshes in the assigned [MeshLibrary].
  132. </description>
  133. </method>
  134. <method name="map_to_local" qualifiers="const">
  135. <return type="Vector3" />
  136. <param index="0" name="map_position" type="Vector3i" />
  137. <description>
  138. Returns the position of a grid cell in the GridMap's local coordinate space. To convert the returned value into global coordinates, use [method Node3D.to_global]. See also [method local_to_map].
  139. </description>
  140. </method>
  141. <method name="resource_changed" deprecated="Use [signal Resource.changed] instead.">
  142. <return type="void" />
  143. <param index="0" name="resource" type="Resource" />
  144. <description>
  145. This method does nothing.
  146. </description>
  147. </method>
  148. <method name="set_cell_item">
  149. <return type="void" />
  150. <param index="0" name="position" type="Vector3i" />
  151. <param index="1" name="item" type="int" />
  152. <param index="2" name="orientation" type="int" default="0" />
  153. <description>
  154. Sets the mesh index for the cell referenced by its grid coordinates.
  155. A negative item index such as [constant INVALID_CELL_ITEM] will clear the cell.
  156. Optionally, the item's orientation can be passed. For valid orientation values, see [method get_orthogonal_index_from_basis].
  157. </description>
  158. </method>
  159. <method name="set_collision_layer_value">
  160. <return type="void" />
  161. <param index="0" name="layer_number" type="int" />
  162. <param index="1" name="value" type="bool" />
  163. <description>
  164. Based on [param value], enables or disables the specified layer in the [member collision_layer], given a [param layer_number] between 1 and 32.
  165. </description>
  166. </method>
  167. <method name="set_collision_mask_value">
  168. <return type="void" />
  169. <param index="0" name="layer_number" type="int" />
  170. <param index="1" name="value" type="bool" />
  171. <description>
  172. Based on [param value], enables or disables the specified layer in the [member collision_mask], given a [param layer_number] between 1 and 32.
  173. </description>
  174. </method>
  175. <method name="set_navigation_map">
  176. <return type="void" />
  177. <param index="0" name="navigation_map" type="RID" />
  178. <description>
  179. Sets the [RID] of the navigation map this GridMap node should use for its cell baked navigation meshes.
  180. </description>
  181. </method>
  182. </methods>
  183. <members>
  184. <member name="bake_navigation" type="bool" setter="set_bake_navigation" getter="is_baking_navigation" default="false">
  185. If [code]true[/code], this GridMap creates a navigation region for each cell that uses a [member mesh_library] item with a navigation mesh. The created navigation region will use the navigation layers bitmask assigned to the [MeshLibrary]'s item.
  186. </member>
  187. <member name="cell_center_x" type="bool" setter="set_center_x" getter="get_center_x" default="true">
  188. If [code]true[/code], grid items are centered on the X axis.
  189. </member>
  190. <member name="cell_center_y" type="bool" setter="set_center_y" getter="get_center_y" default="true">
  191. If [code]true[/code], grid items are centered on the Y axis.
  192. </member>
  193. <member name="cell_center_z" type="bool" setter="set_center_z" getter="get_center_z" default="true">
  194. If [code]true[/code], grid items are centered on the Z axis.
  195. </member>
  196. <member name="cell_octant_size" type="int" setter="set_octant_size" getter="get_octant_size" default="8">
  197. The size of each octant measured in number of cells. This applies to all three axis.
  198. </member>
  199. <member name="cell_scale" type="float" setter="set_cell_scale" getter="get_cell_scale" default="1.0">
  200. The scale of the cell items.
  201. 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.
  202. </member>
  203. <member name="cell_size" type="Vector3" setter="set_cell_size" getter="get_cell_size" default="Vector3(2, 2, 2)">
  204. The dimensions of the grid's cells.
  205. This does not affect the size of the meshes. See [member cell_scale].
  206. </member>
  207. <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
  208. The physics layers this GridMap is in.
  209. 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.
  210. </member>
  211. <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
  212. The physics layers this GridMap detects collisions in. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
  213. </member>
  214. <member name="collision_priority" type="float" setter="set_collision_priority" getter="get_collision_priority" default="1.0">
  215. The priority used to solve colliding when occurring penetration. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.
  216. </member>
  217. <member name="mesh_library" type="MeshLibrary" setter="set_mesh_library" getter="get_mesh_library">
  218. The assigned [MeshLibrary].
  219. </member>
  220. <member name="physics_material" type="PhysicsMaterial" setter="set_physics_material" getter="get_physics_material">
  221. Overrides the default friction and bounce physics properties for the whole [GridMap].
  222. </member>
  223. </members>
  224. <signals>
  225. <signal name="cell_size_changed">
  226. <param index="0" name="cell_size" type="Vector3" />
  227. <description>
  228. Emitted when [member cell_size] changes.
  229. </description>
  230. </signal>
  231. <signal name="changed">
  232. <description>
  233. Emitted when the [MeshLibrary] of this GridMap changes.
  234. </description>
  235. </signal>
  236. </signals>
  237. <constants>
  238. <constant name="INVALID_CELL_ITEM" value="-1">
  239. Invalid cell item that can be used in [method set_cell_item] to clear cells (or represent an empty cell in [method get_cell_item]).
  240. </constant>
  241. </constants>
  242. </class>