using_tilesets.rst 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. .. _doc_using_tilesets:
  2. Using TileSets
  3. ==============
  4. Introduction
  5. ------------
  6. A tilemap is a grid of tiles used to create a game's layout. There are several
  7. benefits to using :ref:`TileMapLayer <class_TileMapLayer>` nodes to design your
  8. levels. First, they let you draw a layout by "painting" tiles onto a grid,
  9. which is much faster than placing individual :ref:`Sprite2D
  10. <class_Sprite2D>` nodes one by one. Second, they allow for larger levels
  11. because they are optimized for drawing large numbers of tiles.
  12. Finally, they allow you to add greater functionality to your tiles with
  13. collision, occlusion, and navigation shapes.
  14. To use TileMapLayer nodes, you will need to create a TileSet first. A TileSet is a
  15. collection of tiles that can be placed in a TileMapLayer node. After creating a
  16. TileSet, you will be able to place them :ref:`using the TileMap editor
  17. <doc_using_tilemaps>`.
  18. To follow this guide, you will need an image containing your tiles where every
  19. tile has the same size (large objects can be split into several tiles). This
  20. image is called a *tilesheet*. Tiles do not have to be square: they can be
  21. rectangular, hexagonal, or isometric (pseudo-3D perspective).
  22. Creating a new TileSet
  23. ----------------------
  24. .. _doc_creating_tilesets_using_tilesheet:
  25. Using a tilesheet
  26. ^^^^^^^^^^^^^^^^^
  27. This demonstration will use the following tiles taken from
  28. `Kenney's "Abstract Platformer" pack <https://kenney.nl/assets/abstract-platformer>`__.
  29. We'll use this particular *tilesheet* from the set:
  30. .. figure:: img/using_tilesets_kenney_abstract_platformer_tile_sheet.webp
  31. :align: center
  32. :alt: Tilesheet example with 64×64 tiles
  33. Tilesheet with 64×64 tiles. Credit: `Kenney <https://kenney.nl/assets/abstract-platformer>`__
  34. Create a new **TileMapLayer** node, then select it and create a new TileSet resource in the inspector:
  35. .. figure:: img/using_tilesets_create_new_tileset.webp
  36. :align: center
  37. :alt: Creating a new TileSet resource within the TileMapLayer node
  38. Creating a new TileSet resource within the TileMapLayer node
  39. After creating the TileSet resource, click the value to unfold it in the
  40. inspector. The default tile shape is Square, but you can also choose Isometric,
  41. Half-Offset Square or Hexagon (depending on the shape of your tile images). If
  42. using a tile shape other than Square, you may also need to adjust the **Tile
  43. Layout** and **Tile Offset Axis** properties. Lastly, enabling the
  44. **Rendering > UV Clipping** property may be useful if you wish tiles to be clipped
  45. by their tile coordinates. This ensures tiles cannot draw outside their allocated
  46. area on the tilesheet.
  47. Set the tile size to 64×64 in the inspector to match the example tilesheet:
  48. .. figure:: img/using_tilesets_specify_size_then_edit.webp
  49. :align: center
  50. :alt: Setting the tile size to 64×64 to match the example tilesheet
  51. Setting the tile size to 64×64 to match the example tilesheet
  52. If relying on automatic tiles creation (like we're about to do here), you must
  53. set the tile size **before** creating the *atlas*. The atlas will
  54. determine which tiles from the tilesheet can be added to a TileMapLayer node
  55. (as not every part of the image may be a valid tile).
  56. Open the **TileSet** panel at the bottom of the editor, then click and drag the
  57. tilesheet image onto the panel. You will be asked whether to create tiles
  58. automatically. Answer **Yes**:
  59. .. figure:: img/using_tilesets_create_tiles_automatically.webp
  60. :align: center
  61. :alt: Automatically creating tiles based on tilesheet image content
  62. Automatically creating tiles based on tilesheet image content
  63. This will automatically create tiles according to the tile size you specified
  64. earlier in the TileSet resource. This greatly speeds up initial tile setup.
  65. .. note::
  66. When using automatic tile generation based on image contents, parts of the
  67. tilesheet that are *fully* transparent will not have tiles generated.
  68. If there are tiles from the tilesheet you do not wish to be present in atlas,
  69. choose the Eraser tool at the top of the tileset preview, then click the tiles
  70. you wish to remove:
  71. .. figure:: img/using_tilesets_eraser_tool.webp
  72. :align: center
  73. :alt: Using the Eraser tool to remove unwanted tiles from the TileSet atlas
  74. Using the Eraser tool to remove unwanted tiles from the TileSet atlas
  75. You can also right-click a tile and choose **Delete**, as an alternative to the
  76. Eraser tool.
  77. .. tip::
  78. Like in the 2D and TileMap editors, you can pan across the TileSet panel using
  79. the middle or right mouse buttons, and zoom using the mouse wheel or buttons in
  80. the top-left corner.
  81. If you wish to source tiles from several tilesheet images for a single TileSet,
  82. create additional atlases and assign textures to each of them before continuing.
  83. It is also possible to use one image per tile this way (although using
  84. tilesheets is recommended for better usability).
  85. You can adjust properties for the atlas in the middle column:
  86. .. figure:: img/using_tilesets_properties.webp
  87. :align: center
  88. :alt: Adjusting TileSet atlas properties in the dedicated inspector (part of the TileSet panel)
  89. Adjusting TileSet atlas properties in the dedicated inspector (part of the TileSet panel)
  90. The following properties can be adjusted on the atlas:
  91. - **ID:** The identifier (unique within this TileSet), used for sorting.
  92. - **Name:** The human-readable name for the atlas. Use a descriptive name
  93. here for organizational purposes (such as "terrain", "decoration", etc).
  94. - **Margins:** The margins on the image's edges that should not be selectable as
  95. tiles (in pixels). Increasing this can be useful if you download a tilesheet
  96. image that has margins on the edges (e.g. for attribution).
  97. - **Separation:** The separation between each tile on the atlas in pixels.
  98. Increasing this can be useful if the tilesheet image you're using contains
  99. guides (such as outlines between every tile).
  100. - **Texture Region Size:** The size of each tile on the atlas in pixels. In most
  101. cases, this should match the tile size defined in the TileMapLayer property
  102. (although this is not strictly necessary).
  103. - **Use Texture Padding:** If checked, adds a 1-pixel transparent edge around
  104. each tile to prevent texture bleeding when filtering is enabled.
  105. It's recommended to leave this enabled unless you're running into rendering issues
  106. due to texture padding.
  107. Note that changing texture margin, separation and region size may cause tiles to
  108. be lost (as some of them would be located outside the atlas image's
  109. coordinates). To regenerate tiles automatically from the tilesheet, use the
  110. three vertical dots menu button at the top of the TileSet editor and choose
  111. **Create Tiles in Non-Transparent Texture Regions**:
  112. .. figure:: img/using_tilesets_recreate_tiles_automatically.webp
  113. :align: center
  114. :alt: Recreating tiles automatically after changing atlas properties
  115. Recreating tiles automatically after changing atlas properties
  116. Using a collection of scenes
  117. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  118. Since Godot 4.0, you can place actual *scenes* as tiles. This allows you to use
  119. any collection of nodes as a tile. For example, you could use scene tiles to
  120. place gameplay elements, such as shops the player may be able to interact with.
  121. You could also use scene tiles to place AudioStreamPlayer2Ds (for ambient
  122. sounds), particle effects, and more.
  123. .. warning::
  124. Scene tiles come with a greater performance overhead compared to atlases, as
  125. every scene is instanced individually for every placed tile.
  126. It's recommended to use only scene tiles when necessary. To draw sprites in a
  127. tile without any kind of advanced manipulation,
  128. :ref:`use atlases instead <doc_creating_tilesets_using_tilesheet>`.
  129. For this example, we'll create a scene containing a CPUParticles2D root node.
  130. Save this scene to a scene file (separate from the scene containing the
  131. TileMapLayer), then switch to the scene containing the TileMapLayer node. Open the TileSet
  132. editor, and create a new **Scenes Collection** in the left column:
  133. .. figure:: img/using_tilesets_creating_scene_collection.webp
  134. :align: center
  135. :alt: Creating a scenes collection in the TileSet editor
  136. Creating a scenes collection in the TileSet editor
  137. After creating a scenes collection, you can enter a descriptive name for the
  138. scenes collection in the middle column if you wish. Select this scenes
  139. collection then create a new scene slot:
  140. .. figure:: img/using_tilesets_scene_collection_create_scene_tile.webp
  141. :align: center
  142. :alt: Creating a scene tile after selecting the scenes collection in the TileSet editor
  143. Creating a scene tile after selecting the scenes collection in the TileSet editor
  144. Select this scene slot in the right column, then use **Quick Load** (or
  145. **Load**) to load the scene file containing the particles:
  146. .. figure:: img/using_tilesets_adding_scene_tile.webp
  147. :align: center
  148. :alt: Creating a scene slot, then loading a scene file into it in the TileSet editor
  149. Creating a scene slot, then loading a scene file into it in the TileSet editor
  150. You now have a scene tile in your TileSet. Once you switch to the TileMap
  151. editor, you'll be able to select it from the scenes collection and paint it like
  152. any other tile.
  153. Merging several atlases into a single atlas
  154. -------------------------------------------
  155. Using multiple atlases within a single TileSet resource can sometimes be useful,
  156. but it can also be cumbersome in certain situations (especially if you're using
  157. one image per tile). Godot allows you to merge several atlases into a single
  158. atlas for easier organization.
  159. To do so, you must have more than one atlas created in the TileSet resource.
  160. Use the "three vertical dots" menu button located at the bottom of the list of
  161. atlases, then choose **Open Atlas Merging Tool**:
  162. .. figure:: img/using_tilesets_open_atlas_merging_tool.webp
  163. :align: center
  164. :alt: Opening the atlas merging tool after creating multiple atlases
  165. Opening the atlas merging tool after creating multiple atlases
  166. This will open a dialog, in which you can select several atlases by holding
  167. :kbd:`Shift` or :kbd:`Ctrl` then clicking on multiple elements:
  168. .. figure:: img/using_tilesets_atlas_merging_tool_dialog.webp
  169. :align: center
  170. :alt: Using the atlas merging tool dialog
  171. Using the atlas merging tool dialog
  172. Choose **Merge** to merge the selected atlases into a single atlas image (which
  173. translates to a single atlas within the TileSet). The unmerged atlases will be
  174. removed within the TileSet, but *the original tilesheet images will be kept on
  175. the filesystem*. If you don't want the unmerged atlases to be removed from the
  176. TileSet resource, choose **Merge (Keep Original Atlases)** instead.
  177. .. tip::
  178. TileSet features a system of *tile proxies*. Tile proxies are a mapping
  179. table that allows notifying the TileMap using a given TileSet that a given
  180. set of tile identifiers should be replaced by another one.
  181. Tile proxies are automatically set up when merging different atlases, but
  182. they can also be set manually thanks to the **Manage Tile Proxies** dialog
  183. you can access using the "three vertical dots" menu mentioned above.
  184. Manually creating tile proxies may be useful when you changed an atlas ID or
  185. want to replace all tiles from an atlas by the ones from another atlas. Note
  186. that when editing a TileMap, you can replace all cells by their
  187. corresponding mapped value.
  188. Adding collision, navigation and occlusion to the TileSet
  189. ---------------------------------------------------------
  190. We've now successfully created a basic TileSet. We could start using in the
  191. TileMapLayer node now, but it currently lacks any form of collision detection.
  192. This means the player and other objects could walk straight through the floor or
  193. walls.
  194. If you use :ref:`2D navigation <doc_navigation_overview_2d>`, you'll also need
  195. to define navigation polygons for tiles to generate a navigation mesh that
  196. agents can use for pathfinding.
  197. Lastly, if you use :ref:`doc_2d_lights_and_shadows` or GPUParticles2D, you may
  198. also want your TileSet to be able to cast shadows and collide with particles.
  199. This requires defining occluder polygons for "solid" tiles on the TileSet.
  200. To be able to define collision, navigation and occlusion shapes for each tile,
  201. you will need to create a physics, navigation or occlusion layer for the TileSet
  202. resource first. To do so, select the TileMapLayer node, click the TileSet property
  203. value in the inspector to edit it then unfold **Physics Layers** and choose
  204. **Add Element**:
  205. .. figure:: img/using_tilesets_create_physics_layer.webp
  206. :align: center
  207. :alt: Creating a physics layer in the TileSet resource inspector (within the TileMapLayer node)
  208. Creating a physics layer in the TileSet resource inspector (within the TileMapLayer node)
  209. If you also need navigation support, now is a good time to create a navigation layer:
  210. .. figure:: img/using_tilesets_create_navigation_layer.webp
  211. :align: center
  212. :alt: Creating a navigation layer in the TileSet resource inspector (within the TileMapLayer node)
  213. Creating a navigation layer in the TileSet resource inspector (within the TileMapLayer node)
  214. If you need support for light polygon occluders, now is a good time to create an occlusion layer:
  215. .. figure:: img/using_tilesets_create_occlusion_layer.webp
  216. :align: center
  217. :alt: Creating an occlusion layer in the TileSet resource inspector (within the TileMapLayer node)
  218. Creating an occlusion layer in the TileSet resource inspector (within the TileMapLayer node)
  219. .. note::
  220. Future steps in this tutorial are tailored to creating collision polygons,
  221. but the procedure for navigation and occlusion is very similar.
  222. Their respective polygon editors behave in the same way, so these steps are
  223. not repeated for brevity.
  224. The only caveat is that the tile's occlusion polygon property is part of a
  225. **Rendering** subsection in the atlas inspector. Make sure to unfold this
  226. section so you can edit the polygon.
  227. After creating a physics layer, you have access to the **Physics Layer** section
  228. in the TileSet atlas inspector:
  229. .. figure:: img/using_tilesets_selecting_collision_editor.webp
  230. :align: center
  231. :alt: Opening the collision editor while in Select mode
  232. Opening the collision editor while in Select mode
  233. You can quickly create a rectangle collision shape by pressing :kbd:`F` while
  234. the TileSet editor is focused. If the keyboard shortcut doesn't work, try
  235. clicking in the empty area around the polygon editor to focus it:
  236. .. figure:: img/using_tilesets_using_default_rectangle_collision.webp
  237. :align: center
  238. :alt: Using default rectangle collision shape by pressing :kbd:`F`
  239. Using default rectangle collision shape by pressing :kbd:`F`
  240. In this tile collision editor, you have access to all the 2D polygon editing tools:
  241. - Use the toolbar above the polygon to toggle between creating a new polygon,
  242. editing an existing polygon and removing points on the polygon. The "three vertical dots"
  243. menu button offers additional options, such as rotating and flipping the polygon.
  244. - Create new points by clicking and dragging a line between two points.
  245. - Remove a point by right-clicking it (or using the Remove tool described above
  246. and left-clicking).
  247. - Pan in the editor by middle-clicking or right-clicking. (Right-click panning
  248. can only be used in areas where there is no point nearby.)
  249. You can use the default rectangle shape to quickly create a triangle-shaped
  250. collision shape by removing one of the points:
  251. .. figure:: img/using_tilesets_creating_triangle_collision.webp
  252. :align: center
  253. :alt: Creating a triangle collision shape by right-clicking one of the corners to remove it
  254. Creating a triangle collision shape by right-clicking one of the corners to remove it
  255. You can also use the rectangle as a base for more complex shapes by adding more points:
  256. .. figure:: img/using_tilesets_drawing_custom_collision.webp
  257. :align: center
  258. :alt: Drawing a custom collision for a complex tile shape
  259. Drawing a custom collision for a complex tile shape
  260. .. tip::
  261. If you have a large tileset, specifying the collision for each tile
  262. individually could take a lot of time. This is especially true as TileMaps
  263. tend to have many tiles with common collision patterns (such as solid blocks
  264. or 45-degree slopes). To apply a similar collision shape to several tiles
  265. quickly, use functionality to
  266. :ref:`assign properties to multiple tiles at once <doc_using_tilemaps_assigning_properties_to_multiple_tiles>`.
  267. Assigning custom metadata to the TileSet's tiles
  268. ------------------------------------------------
  269. You can assign custom data on a per-tile basis using *custom data layers*.
  270. This can be useful to store information specific to your game, such as the damage
  271. that a tile should deal when the player touches it, or whether a tile can be
  272. destroyed using a weapon.
  273. The data is associated with the tile in the TileSet: all instances of the placed
  274. tile will use the same custom data. If you need to create a variant of a tile
  275. that has different custom data, this can be done by :ref:`creating an
  276. alternative tile <doc_using_tilesets_creating_alternative_tiles>` and changing
  277. the custom data for the alternative tile only.
  278. .. figure:: img/using_tilesets_create_custom_data_layer.webp
  279. :align: center
  280. :alt: Creating a custom data layer in the TileSet resource inspector (within the TileMapLayer node)
  281. Creating a custom data layer in the TileSet resource inspector (within the TileMapLayer node)
  282. .. figure:: img/using_tilesets_custom_data_layers_example.webp
  283. :align: center
  284. :alt: Example of configured custom data layers with game-specific properties
  285. Example of configured custom data layers with game-specific properties
  286. You can reorder custom data without breaking existing metadata: the TileSet
  287. editor will update automatically after reordering custom data properties.
  288. With the custom data layers example shown above, we're assigning a tile to have the
  289. ``damage_per_second`` metadata set to ``25`` and the ``destructible`` metadata
  290. to ``false``:
  291. .. figure:: img/using_tilesets_edit_custom_data.webp
  292. :align: center
  293. :alt: Editing custom data in the TileSet editor while in Select mode
  294. Editing custom data in the TileSet editor while in Select mode
  295. :ref:`Tile property painting <doc_using_tilemaps_using_tile_property_painting>`
  296. can also be used for custom data:
  297. .. figure:: img/using_tilesets_paint_custom_data.webp
  298. :align: center
  299. :alt: Assigning custom data in the TileSet editor using tile property painting
  300. Assigning custom data in the TileSet editor using tile property painting
  301. .. _doc_using_tilesets_creating_terrain_sets:
  302. Creating terrain sets (autotiling)
  303. ----------------------------------
  304. .. note::
  305. This functionality was implemented in a different form as *autotiling* in Godot 3.x.
  306. Terrains are essentially a more powerful replacement of autotiles. Unlike
  307. autotiles, terrains can support transitions from one terrain to another, as
  308. a tile may define several terrains at once.
  309. Unlike before, where autotiles were a specific kind of tiles, terrains are
  310. only a set of properties assigned to atlas tiles. These properties are then
  311. used by a dedicated TileMap painting mode that selects tiles featuring
  312. terrain data in a smart way. This means any terrain tile can be either
  313. painted as terrain or as a single tile, like any other.
  314. A "polished" tileset generally features variations that you should use on
  315. corners or edges of platforms, floors, etc. While these can be placed manually,
  316. this quickly becomes tedious. Handling this situation with procedurally
  317. generated levels can also be difficult and require a lot of code.
  318. Godot offers *terrains* to perform this kind of tile connections automatically.
  319. This allows you to have the "correct" tile variants automatically used.
  320. Terrains are grouped into terrain sets. Each terrain set is assigned a mode from
  321. **Match Corners and Sides**, **Match Corners** and **Match sides**. They define how
  322. terrains are matched to each other in a terrain set.
  323. .. note::
  324. The above modes correspond to the previous bitmask modes autotiles used in
  325. Godot 3.x: 2×2, 3×3 or 3×3 minimal. This is also similar to what
  326. the `Tiled <https://www.mapeditor.org/>`__ editor features.
  327. Select the TileMapLayer node, go to the inspector and create a new terrain set within the TileSet *resource*:
  328. .. figure:: img/using_tilesets_create_terrain_set.webp
  329. :align: center
  330. :alt: Creating a terrain set in the TileSet resource inspector (within the TileMapLayer node)
  331. Creating a terrain set in the TileSet resource inspector (within the TileMapLayer node)
  332. After creating a terrain set, you **must** create one or more terrains *within* the terrain set:
  333. .. figure:: img/using_tilesets_create_terrain.webp
  334. :align: center
  335. :alt: Creating a terrain within the terrain set
  336. Creating a terrain within the terrain set
  337. In the TileSet editor, switch to Select mode and click a tile. In the middle
  338. column, unfold the **Terrains** section then assign a terrain set ID and a
  339. terrain ID for the tile. ``-1`` means "no terrain set" or "no terrain", which
  340. means you must set **Terrain Set** to ``0`` or greater before you can set
  341. **Terrain** to ``0`` or greater.
  342. .. note::
  343. Terrain set IDs and terrain IDs are independent from each other. They also
  344. start from ``0``, not ``1``.
  345. .. figure:: img/using_tilesets_configure_terrain_on_tile.webp
  346. :align: center
  347. :alt: Configuring terrain on a single tile in the TileSet editor's Select mode
  348. Configuring terrain on a single tile in the TileSet editor's Select mode
  349. After doing so, you can now configure the **Terrain Peering Bits** section which
  350. becomes visible in the middle column. The peering bits determine which tile will
  351. be placed depending on neighboring tiles. ``-1`` is a special value which refers
  352. to empty space.
  353. For example, if a tile has all its bits set to ``0`` or greater, it will only
  354. appear if *all* 8 neighboring tiles are using a tile with the same terrain ID.
  355. If a tile has its bits set to ``0`` or greater,
  356. but the top-left, top and top-right bits are set to ``-1``, it will only appear
  357. if there is empty space on top of it (including diagonally).
  358. .. figure:: img/using_tilesets_configure_terrain_peering_bits.webp
  359. :align: center
  360. :alt: Configuring terrain peering bits on a single tile in the TileSet editor's Select mode
  361. Configuring terrain peering bits on a single tile in the TileSet editor's Select mode
  362. An example configuration for a full tilesheet may look as follows:
  363. .. figure:: img/using_tilesets_terrain_example_tilesheet.webp
  364. :align: center
  365. :alt: Example full tilesheet for a sidescrolling game
  366. Example full tilesheet for a sidescrolling game
  367. .. figure:: img/using_tilesets_terrain_example_tilesheet_configuration.webp
  368. :align: center
  369. :alt: Example full tilesheet for a sidescrolling game with terrain peering bits visible
  370. Example full tilesheet for a sidescrolling game with terrain peering bits visible
  371. .. _doc_using_tilemaps_assigning_properties_to_multiple_tiles:
  372. Assigning properties to multiple tiles at once
  373. ----------------------------------------------
  374. There are two ways to assign properties to multiple tiles at once.
  375. Depending on your use cases, one method may be faster than the other:
  376. Using multiple tile selection
  377. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  378. If you wish to configure various properties on several tiles at once,
  379. choose the **Select** mode at the top of the TileSet editor:
  380. After doing this, you can select multiple tiles on the right column by holding
  381. :kbd:`Shift` then clicking on tiles. You can also perform rectangle selection by
  382. holding down the left mouse button then dragging the mouse. Lastly, you can
  383. deselect tiles that were already selected (without affecting the rest of the
  384. selection) by holding :kbd:`Shift` then clicking on a selected tile.
  385. You can then assign properties using the inspector in the middle column of the
  386. TileSet editor. Only properties that you change here will be applied to all
  387. selected tiles. Like in the editor's inspector, properties that differ on
  388. selected tiles will remain different until you edit them.
  389. With numerical and color properties, you will also see a preview of the
  390. property's value on all tiles in the atlas after editing a property:
  391. .. figure:: img/using_tilesets_select_and_set_tile_properties.webp
  392. :align: center
  393. :alt: Selecting multiple tiles using the Select mode, then applying properties
  394. Selecting multiple tiles using the Select mode, then applying properties
  395. .. _doc_using_tilemaps_using_tile_property_painting:
  396. Using tile property painting
  397. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  398. If you wish to apply a single property to several tiles at once,
  399. you can use the *property painting* mode for this purpose.
  400. Configure a property to be painted in the middle column, then
  401. click on tiles (or hold down the left mouse button) in the right column
  402. to "paint" properties onto tiles.
  403. .. figure:: img/using_tilesets_paint_tile_properties.webp
  404. :align: center
  405. :alt: Painting tile properties using the TileSet editor
  406. Painting tile properties using the TileSet editor
  407. Tile property painting is especially useful with properties that are
  408. time-consuming to set manually, such as collision shapes:
  409. .. figure:: img/using_tilesets_paint_tile_properties_collision.webp
  410. :align: center
  411. :alt: Painting a collision polygon, then left-clicking tiles to apply it
  412. Painting a collision polygon, then left-clicking tiles to apply it
  413. .. _doc_using_tilesets_creating_alternative_tiles:
  414. Creating alternative tiles
  415. --------------------------
  416. Sometimes, you want to use a single tile image (found only once within the
  417. atlas), but configured in different ways. For example, you may want to use the
  418. same tile image, but rotated, flipped, or modulated with a different color. This
  419. can be done using *alternative tiles*.
  420. .. tip::
  421. Since Godot 4.2, you don't have to create alternative tiles to rotate or
  422. flip tiles anymore. You can rotate any tile while placing it in the
  423. TileMap editor by using the rotation/flip buttons in the TileMap editor
  424. toolbar.
  425. To create an alternative tile, right-click a base tile in the atlas displayed by
  426. the TileSet editor, then choose **Create an Alternative Tile**:
  427. .. figure:: img/using_tilesets_create_alternative_tile.webp
  428. :align: center
  429. :alt: Creating an alternative tile by right-clicking a base tile in the TileSet editor
  430. Creating an alternative tile by right-clicking a base tile in the TileSet editor
  431. If currently in Select mode, the alternative tile will already be selected
  432. for editing. If not currently in Select mode, you can still create alternative
  433. tiles, but you will need to switch to Select mode and select the alternative
  434. tile to edit it.
  435. If you don't see the alternative tile, pan over to the right of the atlas image,
  436. as alternative tiles always appear on the right of base tiles of a given atlas
  437. in the TileSet editor:
  438. .. figure:: img/using_tilesets_configure_alternative_tile.webp
  439. :align: center
  440. :alt: Configuring an alternative tile after clicking it in the TileSet editor
  441. Configuring an alternative tile after clicking it in the TileSet editor
  442. After selecting an alternative tile, you can change any properties using the
  443. middle column like you would on a base tile. However, the list of exposed
  444. properties is different compared to base tiles:
  445. - **Alternative ID:** The unique numerical identifier for this alternative tile.
  446. Changing it will break existing TileMaps, so be careful! This ID also controls
  447. the sorting in the list of alternative tiles displayed in the editor.
  448. - **Rendering > Flip H:** If ``true``, the tile is horizontally flipped.
  449. - **Rendering > Flip V:** If ``true``, the tile is vertically flipped.
  450. - **Rendering > Transpose:** If ``true``, the tile is rotated 90 degrees
  451. *counter-clockwise* and then flipped vertically. In practice, this means that
  452. to rotate a tile by 90 degrees clockwise without flipping it, you should
  453. enable **Flip H** and **Transpose**. To rotate a tile by 180 degrees
  454. clockwise, enable **Flip H** and **Flip V**. To rotate a tile by 270 degrees
  455. clockwise, enable **Flip V** and **Transpose**.
  456. - **Rendering > Texture Origin:** The origin to use for drawing the tile. This
  457. can be used to visually offset the tile compared to the base tile.
  458. - **Rendering > Modulate:** The color multiplier to use when rendering the tile.
  459. - **Rendering > Material:** The material to use for this tile. This can be used
  460. to apply a different blend mode or custom shaders to a single tile.
  461. - **Z Index:** The sorting order for this tile. Higher values will make the tile
  462. render in front of others on the same layer.
  463. - **Y Sort Origin:** The vertical offset to use for tile sorting based on its Y
  464. coordinate (in pixels). This allows using layers as if they were on different
  465. height for top-down games. Adjusting this can help alleviate issues with
  466. sorting certain tiles. Only effective if **Y Sort Enabled** is ``true`` on
  467. the TileMapLayer node under **CanvasItem > Ordering**
  468. You can create an additional alternative tile variant by clicking the large "+"
  469. icon next to the alternative tile. This is equivalent to selecting the base tile
  470. and right-clicking it to choose **Create an Alternative Tile** again.
  471. .. note::
  472. When creating an alternative tile, none of the properties from the base tile
  473. are inherited. You must set properties again on the alternative tile if you
  474. wish those to be identical on the base tile and the alternative tile.