Tilemap custom data detection in script

Question

Guys, i am trying to detect if a characterBody2D is stepped on an specific tile in a Top-Down 2D game.I dont know how to check if the player is stepped on that tile. I want too to make the conveyor belt out of that. Help will be appreciated.

Script

For now i have that👇 but it doesnt work heh.

extends TileMap

signal ConveyorActivated

@onready var character_body_2d = $“…/CharacterBody2D”
@onready var tile_map = $“.”

var data = “Conveyor”

func _physics_process(delta):

var tileData :TileData = tile_map.get_cell_tile_data(0, Vector2i.ZERO)
var conveyorData = tileData.get_custom_data(data)
print(“TestData: {0}”.format([conveyorData]))

Does your conveyor have a tile id? You could do something like this: How to set up a tile in a tilemap to detect the player or another object? - #2 by system (see the comments)

1 Like

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