How to get custom data from tiles

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Maximm

So I’ve been working on a platformer game for a little while now and have been wondering how I could get the custom data layers out of the tiles that I collide with. (mainly using a raycast2D)

The reason is so that I can check if I could wall jump off a wall or not, depending on what tile I am colliding with.

you maybe not need to use custom data just to figure out what tile it is?
can use source_id and coords and alternative_id to tell what tile it is
TileMap — Godot Engine (stable) documentation in English

func _isForeTile(p: Vector2i, tiles: Array) -> bool:
	return tiles.has(_tileMap.get_cell_source_id(Layer.Fore, p))

func isWall(p: Vector2i) -> bool:
	return _isForeTile(p, _wallTiles)

for example here is part of my wall check code
i just get the source_id of tile at point and check if it from one of my wall atlas

and here i check for a specific tile:

func isStair(p: Vector2i) -> bool:
	return _isForeTile(p, _stairTiles)

func isStairUp(p: Vector2i) -> bool:
	var source = _sources[_tileMap.get_cell_source_id(Layer.Fore, p)]
	return isStair(p) and _tileMap.get_cell_atlas_coords(Layer.Fore, p) == source.get_tile_id(Stair.Up)

func isStairDown(p: Vector2i) -> bool:
	var source = _sources[_tileMap.get_cell_source_id(Layer.Fore, p)]
	return isStair(p) and _tileMap.get_cell_atlas_coords(Layer.Fore, p) == source.get_tile_id(Stair.Down)

but here is an interesting custom data video:
https://www.youtube.com/watch?v=k9RsnbP4a0c

rakkarage | 2023-06-24 03:43

Well I think that I actually would want to use custom tile data because how to make the game is that I would have tiles that let you wall jump off and that don’t, but it’s not just one or two, it would be a different tileset every level.

Maximm | 2023-06-25 19:49