Looping over tilemap layers

Godot Version

4.5.1

Question

Hello,

I’m new to Godot. Putting together a really simple 2D RPG for fun. I have built my map from tilemap layer nodes instead of the deprecated tilemap node.

On each layer node is an element e.g. water, ground, buildings etc. This seemed intuitive, as I wanted to give each element different meta attributes/collisions.

But now I want to loop over my whole map, to spawn baddies and pickups. Except, because I’m working with a set of layers instead of a single, referencable ‘map’ node, I’m not sure how to do this.

Is there a way of wrapping up my tilemap layers back into a single ‘container’ map that I can loop through?

Thanks in advance!

Put references to layer nodes in an array and loop through the array elements.

I think I may have solved this. Tilemap layers share cell coordinates, which I hadn’t realised. So it’s then just a matter of checking the same coordinates on each tilemap layer to see if it is free. Right?