Closed ninjatronic closed 1 year ago
Hi, there is indeed a way to get the custom data defined from the importer. I have plans to make this experience easier, but for now, you can access the tile data by deserializing the json data, then traversing through it until you can access the CustomData from the TilesetDefinition:
You can access and deserialize the data from this scriptableobject asset from the imported project with the function FromJson()
:
Let me know if this solution can work for you 🙂
My LDTK project saves levels as separate files and as such I'm struggling to find a way to access this JSON object in code. I can see it in the assets in the project explorer but when I drop the LDTK project file into the scene in the hierarchy it does not show these children. Is it possible for you to show a simple code example as to how I would access this? Sorry for the noob question, I'm new to Unity and LDTK. Many thanks.
This function in particular will be useful for your situation, where you can traverse the project json to access definitions and additionally levels and their used tilesets in that way.
And you can check here to understand how the LDtk postprocessing works.
Also feel free to join the Discord server where I can provide quicker answers. I didn't realize you had responded here recently after my previous post 😅
Another significantly easier option is defining intgrid values to describe where your character should change it's speed. then you can make your character check for an IntGridTile existing at a position, and check if it matches a reference you are checking for. And voila :) Let me know if that can work out for you.
Custom tile data is now available in the newest update! (4.0.0) You get a tileset tile from the tilemap, which will contain both the custom data and enum values.
Hi. Apologies for the noob question but I'm coming up against a brick wall here.
I have a tileset "Ground" which has custom data for each tile using the following schema...
I've imported the world into unity and put the level in the scene. In code I can get the tile under the player's current position...
But from here I am drawing a blank on how to access the custom data associated with this tile. Any help is much appreciated. Thanks for the excellent project so far it has been very useful.