I am working on a 2d top down RPG and was wondering if anyone has any ideas how if Tiled can solve this problem or not.
The use case is lets take “scene_1_forest”. I create the Tiled map and use Tiled2Unity to import that into Unity. This gives me a prefab that I can now drag into my scene. Lets say the only thing on that screen is a tree that needs to be cut down for the storyline. I am trying to figure out how to conditionally show that image in the game. The two conditions are
- New game - show the tree
- After storyline part - never show the tree again.
My only solution I can think of is to create two different maps in tiled basically showing the same thing just with/without the tree. This solution doesn’t work however if I have like 10 trees on the map and each one can be cut down and disappear forever.
To clarify basically I would have to have two tiled maps of scene_1_forest_with_tree and scene_1_forest_without_tree and I really don’t want to do that. If I have more than 1 element per map I couldn’t make all of the maps needed for this conditional.
I don’t know much about Tiled2Unity. Would it be possible to show/hide an entire map layer?
I think you’ll want the tree to be instantiated as a game object, so that you can easily remove the trees one-by-one and also store which trees have been removed in the savegame so you can despawn (or avoid spawning) those after loading the map. It should be possible to set up the Tiled2Unity export to create game objects for some things.
To elaborate on what bjorn said, it’s quite easy to convert a layer in tiled to sprites. I’ve done it in Monogame, so it should be a little bit less work in unity? You’d want to loop through all the tiles on a given layer, and for a filled tile, create a new sprite at the given position, with a texture from the texture region for the tile. You may have to adjust/fix your offset because the tiles are usually in the corner.
Yeah, currently we are using Tiled only for the background (basically anything that isn’t interactable) and then in Unity putting the ‘tree’ into a prefab and hand placing them onto the map.
Yeah, the removing one by one and storing which tree we touched is exactly what we want. Not totally sure how to set up the game object in Tiled or how to have Tiled2Unity pick this up. I know how to draw the “object” around a sprite in Tiled in the object layer, but is that what I want to do?