Tilemap Collider 2D

So i have my sprite with rigidbody, and a collider on it - it can use my “door” portal thing fine - it can interact with other rigidbodies - and using a boxcollider 2d this works - however im trying to use tilemap collider 2d as trigger for this script - however just writing “Collider2D Col” in the constructor, does not work ? Anyone have a solution? I basically just need to know what its called, because TilemapCollider2D is not its name, nor is TileMapCollider2D - this is the error it gives me


“nterScript.cs(14,27): error CS0246: The type or namespace name TilemapCollider2D' could not be found. Are you missing UnityEngine.Tilemaps’ using directive?”


Also yes, the script is ON the tilemap in question. Does anyone know the correct syntax? Or know how i can have it interact.


Here’s the code

void OnTriggerEnter2D(TilemapCollider2D col) //<--- THIS is the issue. 
                                                                 // There exists no reference to tilemap collider 2d's collision.
                                                                 // And if there does, then i need to know what it is?  Cant find it.
    {
        if (col.GetComponent<Player>())
        {
            Debug.Log("TestTileWorking?");
            
        }
    }

Edit1: - like i said to the person below, i know how tilemaps work, this specific tilemap is a child of its parent tilemap, this tilemap has enabled “isTrigger” Imgur: The magic of the Internet and only contains the relevant tiles to trigger the script above- the PROBLEM, is, that the reference INSIDE THE SCRIPT - is not “TilemapCollider2D” - so then what is it? Because it isnt “Collider2D” - when i add a box2d collider i can use the script normally- but i want to very specifically use several individual tiles as encounters.

Edit2: - Still no luck, tried composite collider, with no result. Surely there must be a reference ? Obviously you’d want specific tiles on your tilemaps to have an effect?

I think you are trying to use Tilemap colliders in a way they are not meant to be used. The way I understand it, Tilemap colliders are used to automtically create the collisions of the tilemap it is added to (All of the tiles will be affected). What you may be looking for is the Edge Collider 2D, which can act as a trigger and a collider.

Another solution using Tilemap collider could could be to create a child tilemap and paint there the tiles that need to trigger the script. This way every time you add a tile to this tilemap, it will already have the collider/trigger.

Figured it out - i hadnt checked that the tile itself had “none” instead of “sprite” collision, worked after that.