How to convert Tilemap to Tilemaplayer?

Godot Version

4.3

Question

Hi, Im trying to convert a tilemap to a tilemaplayer.

I can go to the tilemap scene and use the extract thing, then it adds a tilemaplayer node.

But what happens to the nodes which use my tilemap scene? Apparently, the tilemap still keeps its layers when the scene is used as a node.

This means I have to redraw all tiles manually because the drawn tiles remain on the Tilemap node?

How do I fix this?

see the screenshot

Can you show your tilemap-scene?

It also creates a window for a second which says something like ā€œThere is already a layer0ā€

Well you dont need the tilemap anymore. You only need the layer-node. You can right-click the layernode and click ā€œMake Rootā€ and then you can delete the tilemap-node.
Before you delete make sure everything has been converted correctly

That process deletes all my tiles I have drawn inside the tilemap node in my EternalPlains.tscn where I use the scene as a node.

Then you have to convert them in these scenes as well

Then you get a local node which is no longer in sync with the tilemap(layer)scene that is used in other scenes.

It seems then that you have to copy the drawn tiles packedbytearray yourself in the tscn raw editor.

Whats the point of your tilemap-scene at all?

To reuse it in various scenes.

But it doesnt contain any tiles does it?

No, but properties like scale, zindex, sometimes with a script. With the reusable scene, no need to manually set these values.

Yeah in this case the conversion wont really be working how you want it

1 Like

If anyone else has the same problem, here is my current solution (similar to the one above):

  1. Extract TilemapLayer in all scenes where the tilemap is used.
  2. Change the type of the tilemap in the tilemap scene to TilemapLayer (Change Type has the advantage of retaining the properties).
  3. In all scenes where the tilemap is used, copy the tiles from the extracted layer to the tilemap scene node (either in the editor with the selector or by copying from the tscn file as suggested by @godotuser6000).
  4. Delete the layer.

For multiple layers, Iā€™m essentially doing the same but converting the tilemap to a Node2D. Then, you can either attach the layers directly in the tilemap scene and expose them via ā€˜Editable Childrenā€™ to draw (seems hackish), or make each layer a separate scene and instantiate them in every scene as a child of the main tilemap Node2D.

Itā€™s annoying, but I guess itā€™s better than redrawing all the tiles.
If there is a better solution, please let me know :).

4 Likes

Could you elaborate on Step 3.?

So, the idea is to copy all the tiles that you have drawn from the extracted TileMapLayer to the new TileMapLayer scene. To do this, you select the extracted TileMapLayer node. Then you can select all the drawn tiles by selecting the ā€˜Selectā€™ tool (pointer icon) in the TileMap menu in the bottom panel. After selecting them, you copy and paste them to the TileMapLayer scene. After that, you can delete the extracted layers.

Alternatively, instead of using the Editor GUI, you can open the .tscn file where you have drawn the tiles and copy the tile information (I havenā€™t tried this myself).

1 Like

Thatā€™s a great answer, which I havenā€™t tried yet but I did something similar before (copying the tiles from map to map). Now Iā€™ve got the TileMap in a Scene that is inherited by other scenes (not instantiated in them) to be able to reference it from a common script. If itā€™s not working Iā€™m coming back to this post here to figure out any alternatives.