Accessing custom data in Tile Set not returning expected

Godot Version



I am running into issues with getting custom data on a tileset. This is my code:

position = Vector2(startingPosition)
newPosition = position
var hovered_cell = tile_map.local_to_map(newPosition)
var type_name = tile_map.tile_set.get_custom_data_layer_by_name("tileType")
var data = tile_map.get_cell_tile_data(0, hovered_cell)
if data.get_custom_data("tileType") == "stairs":
    print("Stairs hovered")

Right now when I try to print data, nothing is printed, neither does the print inside the if statement. The only print that is working is print(type_name), which returns the layer of the custom data (0).
What I want to do is return the tile type on the custom data I created inside the TileSet. Here is an example of where I have the data added on the tiles.
Screenshot 2024-02-28 233852

Are the cells that contain the custom data in layer 0 of your tilemap?

I think so. I changed it to 1 because that’s the layer they say they’re in but I get a null error when I did that

I figured it out :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.