• 2D
  • Interacting with tilemaps.

Is there a way to code some of the tileset(map) into the scrips? (top down game style) For example, when the player walks over "grey tile" it changes to "Blue tile" or something similar? Especially if 'player' has a specific item equipped.

I've built a small test map with the tilesets and it working beautifully with collisions, I can't seem to find a way to reference the tiles for the script to see it in the godot manuals.

Thanks again everyone! Best community I've ever been with,

The only way I can think of that would make this possible is if you made the tiles you want to change a separate entity from the tilemap.

Take your example. You could make a scene where the blue tiles exist, and then have a script on it that would check for collision between it and the player, and then change into a different tile.

I tried to do something fairly similar with my own tilemaps a while ago, but also couldn't get it to work so had to come up with a different solution.

12 days later

If you have the collision position (for example because your player is a KinematicBody2D) you can use that position in to get the cell/type in the tilemap. Don't forget to check if it is the floor by looking at the collision-normal. Example:


var tile_pos = tilemap.world_to_map(global_pos)
var cell = tilemap.get_cellv(tile_pos)
if cell == 3: # thetilesets tile id
	tilemap.set_cellv(tile_pos, 4)
2 years later

In this case, would the cell correspond to a particular cell number on the grid or to a specific tile that was placed? And how would we find out the tile id #?

3 years later

To find the cell id just put the 2 first lines in a func process(): or in a func physic_process(): and print the var cell,it will print the cell id where the player go