How to Add C++ Class Functionality or Blueprints to Tiles within a TileSet and/or TileMap?

What I am trying to do: I have been trying to create a top down tile based game using Unreal’s Paper2D functionality. I was wondering if it was possibly to add class functionality to tile within the TileSet and/or the TileMap.

Problem: My overarching problem is that I am unable to add objects to the tile map that have functionality beyond collision. I would like to refrain from just placing something on top of my TileMap within the level. I feel that the TileMap would be more coherent if all the objects could be placed within the TileMap editor.

Example: For example, how would I go about creating a tile like a pressure plate that would trigger when it was stepped on by the player. If I create a class/blueprint that has all the functionality of my pressure plate how can I apply it to my Tile within the TileSet to make sure that the tile’s behavior is consistent when placed within the TileMap.

Additional Info: I did see in the TileSet editor that there is an option to add meta data to a tile, but the only metadata that can be added is a single string. Furthermore, the TileSet editor recommends that I use the Tile’s metadata as an index within a DataTable. Is this metadata something that I could use to attach a class to a given Tile by referencing the DataTable.

Thank you very much for your time and consideration in reading this post. I look forward to hearing back from you. Thanks again for the help.

I’m wondering the same as well, did you ever solve this?

Alright, I figured it out with Blueprint (you can probably do it in C++ though). Even though you’ll probably never see this, hopefully someone will come across it - as there’s basically no documentation on these features.

Alright, so step 1 is to get your tileset from a texture. For my example, I’ll be using some classic Zelda sprites courtesy of ‘Darth RPG’. The tileset size I’m using is 16x16, which will be important down the line.

Step 2 is to set up both collision AND metadata on the tile in question you want to perform the blueprint functionality. I’ll be using a staircase. To set up the metadata, input text into the “Used Data Name” field. For my example, I’m using the string “Stairs”. Also note from the image, my collision doesn’t encompass the entire tile. It’s more like 9x9 for 16x16 tile.

Place your tilesets on your tile map, and then place that in the world. This is my example scene, that allows me to test the collision of the pillars, and my staircase in the middle.

NOW comes the big important step, the blueprint. Long story short, when we hit collision, we want to get the metadata of the tile we’re colliding with. Unfortunately there is no “get tile” for this sort of thing, so we have to make one. I’m doing this in my character, but you would probably be better off doing this in a component or fired off via a function.
In this code, I start off Event Hit (an occurance for any collision event) and take the Hit result. Breaking the hit result I get the hit actor, and cast to PaperTileMapActor. Getting the casted actor’s location, the location of our tilemap, I subtract the Impact Point from the Hit Result to get the aproximate position of our tileset.
That point needs to be converted to a tile that can be found, and Metadata extracted from. Breaking the vector from that subtraction node, I get the X and Y values and divide them by my tile size (16). These values might get sketchy if you aren’t working on a 1,1,1 scale like I am, and you’ll probably need to multiply them by a scale if you aren’t - but regardless, you’ll want to round the divided results. In my example I invert my Y value but that might not be nescessary depending on your setup.
The imporant step, is for you to finally get the render component from the PaperTileMapActor you casted to earlier, and “Get Tile” from it. Input the rounded X and Y values into the appropriate slots. From there you perform the final and most important step: “Get Tile User Data”, which will hopefully return the Text of the tile’s Metadata.

The end result, from by debug outputs, is the Metadata text for the tile. From there, it’s easy enough. Perform a switch case statement on the metadata names to perform whatever function you want. The nice thing about this solution is that if I ever want any staircase in any tileset to perform the same function, I’d just have to give it the metadata of “Stairs”.

Thank you.
Not elegant, but I think it’s quite workable. Came similar ideas in the head.

I wanted use custom cells with many sprites, i mean just sprites with flipbook without tiles, used constuctor script for support our custom cells. So, But i thing it’s a large overload of the scene, m.b. tilemaps will be best solution.


you can use this methods for calculable position

I never did solve this because I made this post awhile ago and I was still new to Unreal and Paper2D thought it was never going to get answered but Chaosian gave a beautifully crafted answer below here.

I thought this problem was never going to get answered. Over the past couple months or so I have really gotten back into Unreal development so I just now saw your answer Chaosian. I wanted to thank you for giving such a well thought out and beautifully crafted answer. Thank you very much for your time it is very much appreciated. When I go back to making projects using Paper2D I will definitely be referencing this.

Someone thought about the logic of determining the surface to play a certain sound of walking depending on the surface?
I understand… we can use key or composite_key that do it, but m.b. exist more elegant way.
Or use invisible collision.
If i can get layer name, that can be key.

Hello all, I m trying to edit tiles in runtime… is possible? Like destroy one simple tile? I manage to do that with GroupPaperSprite but its not the best way I think… I trying to remove a simple tile with this…

Thank you very much for your time and consideration in help me too. I look forward to hearing back from you. Thanks again for the help.