c# – Unity: Detect which tile in a tile palette a player is colliding with


I had a quick question regarding Unity that I was hoping someone might be able to help me with.

I have a megaman-style platformer that I’ve been working on for a while now. In my game, I’d like to be able to have my scene set up so that when a player interacts with certain tiles, it will have some sort of effect on the player. This could easily be achieved with creating individual sprites for the aforementioned interactables, but I’d ideally like to be able to have a portion of my script handle it so that everything besides the player and enemies would be tilemaps.

For instance, I have a tile that would act as a treadmill that moves the player along in one direction. Another tile would be bouncy, and another would deal damage. I have the game set up right now to detect when the player is touching a tile, but I have no way of being able to tell which tile the player is touching. Is there a way to be able to compare programmatically which tile from a tile palette my player’s hitbox is currently touching?

Thanks in advance! I’d be happy to answer any questions related to how things are set up in my project if needed.