How do you work with TileMapLayer?

Godot Version

4.3

Question

How do you work with tilemaplayer? are there any recommendations for using it? i mean, when you spawn game objects on the map, do you put them inside the tilemaplayer or keep them as children outside?

Some examples:

or:

Or maybe it is only needed for drawing the background and game objects should not be inside it?

I will be grateful for any advice/instructions you may give me!

1 Like

TileMapLayers are used to render different layers and tilesets. For example, let’s say you are making a 2d platformer and want to have ground to stand on, then some hills and a sky in the background. Well, the way you would set this up is as follows:

  • First, create a new TileMapLayer and add your ground tilemap; this will also be the layer with your coalition shapes, excluding enemies and moving platforms.
  • Second, create another TileMapLayer, add your hills tilemap, and then add a ParallaxBackgound node. This will add the ability to add depth to your game. With your ParallaxBackgound, add a child ParallaxLayer node, then put your hills as a child of the ParallaxLayer.
  • Third, Repeat step 2 for the sky, but add the ParallaxLayer and the Sky tilemap.
  • Lastly, adjust the scale and offset of the ParallaxLayers so it suits your style

With that completed, you should end with a result looking like this:
Tilemap image_2024-12-02_000316461

1 Like