How to copy physics & terrain settings to add variety to a tileset

Godot Version

4.5.1

Hi, I’m trying to make a tileset that has multiples of each tile with small visual variations. I can merge several .png files containing the altered tiles, but then I have to manually redo all of the physics and terrain settings for each copy.

This seems like a simple thing, but I can’t find info anywhere on how to do this! Is there some way to copy/paste or duplicate existing tiles, along with their physics & terrain, to create graphical variations?

Thanks!

class_name YourTileMapBaseClass
extends TileMapLayer


## Shared Physics/Settings

class_name TileN
extends YourTileMapBaseClass

## Everything specific to this tile
1 Like

Ah, I see. So instead of doing it in the graphical editor, I do it in code and just swap out the .png file that’s referenced. I assume there’s an easy way to extract the physics & terrain settings from the first set that I do manually so that I can reproduce it in code?

Thanks,

Douglas

Godot files are all text. You can open up scene files and get what you want. For example:

[node name="Objects" type="TileMapLayer" parent="GameArea/CanvasLayer"]
scale = Vector2(4, 4)
tile_map_data = PackedByteArray("nope_nope_nope")
tile_set = ExtResource("2_0vl8b")

The specifics for your changes should be found there (assuming you have not saved them to a script file).

Great, I’ll poke around in the saved files. Thank you.

For future reference – it was way easier than I thought it would be.

  • make a tileset, add an image in Tile Sources, configure it how you want it, paint the physics & terrain, etc
  • add another image (with identical layout) to Tile Sources.
    • DO NOT CONFIGURE/PAINT THIS IMAGE. Just add it.
  • save the Tile Set via the drop down menu next to it in the Inspector
  • leave the scene (just to be safe)
  • open the tileset.tres (or whatever you called it) file in a text editor
  • you’ll see that for the first image there’s lots of information about physics, terrain, etc
  • you’ll see that for the second image, there are indexes, but no info next to them
  • simply copy all of the info from the first image (NOT INCLUDING the info that ID’s that image)
  • delete all of the info from the 2nd image, and paste in the info from the 1st image
  • save the file, reload the scene

So if you see this for the first image:

[sub_resource type=“TileSetAtlasSource” id=“TileSetAtlasSource_xouh1”]
texture = ExtResource(“1_4olan”)
4:5/0 = 0
4:5/0/terrain_set = 0
4:5/0/terrain = 0
4:5/0/physics_layer_0/polygon_0/points = PackedVector2Array(4, 8, 4, 4, 8, 4, 8, -4, -4, -4, -4, 8)
4:5/0/terrains_peering_bit/right_side = 0
4:5/0/terrains_peering_bit/bottom_side = 0

You start copying at 4:5/0 = 0. Copy everything that’s formatted like that, until you get to similar (but much sparser) info for the 2nd image. Delete all the entries for the 2nd image and paste in the entries for the first image.

THAT’S IT! Because the images are identical in layout, the indexing information is exactly the same.

Thanks that_duck for sending me down the right path!

Douglas