Tilemap => possible to sort z-values of each tile separately?

Hi!

Everything is in the title :slight_smile:

I think I know the answer, but I need to be sure before starting to test time-consuming solutions/workarounds.

Is there a way to sort z-values of each tile separately?

(if not possibleā€¦ would be pretty convenient :thinking:)

No, Iā€™m afraid not.

1 Like

Ok thank you!

It was for that kind of situation (already mentioned in another post so Iā€™m not surprised by the answer)
image

I think Iā€™ll just add a custom property (ex: game object ā€œIDā€) to some tiles and spawn game objects over them to manage the z-order with the characters.

(but the feature mentioned above may still be interesting in the future :grin:)

Have you tried adding those ā€œtopā€ pieces in a different layer of the tilemap, with a higher z-value?

1 Like

@Mathias_Westerdahl
It was my first move, but my map will be much bigger and probably ā€œdynamicallyā€ generated (not sure about how to implement thatā€¦ Iā€™ll create a dedicated topic :see_no_evil:), with the same objects, displayed many times:

Example of a ā€œdungeonā€ built by the player (vertical growth always based on the same type of ā€œroomsā€):

I would need many, many layers to do what I have in mindā€¦ wouldnā€™t I?

So I thought that it would be way easier to spawn game objects over the tiles in question (with the exact same sprite so players wonā€™t make the difference), and then just make sure theyā€™re always over the characters.

I donā€™t think so?

my map will be much bigger and probably ā€œdynamicallyā€ generated (not sure about how to implement that

The files are in text format, so should be easy to generate

2 Likes
  • If the player is always behind the tops of the pillars, then you just need one extra layer.

  • If the player can be in front of or behind them at different times, then you need game objects with some sort of dynamic Y-sorting.


I think thereā€™s a couple threads about dynamic level generation. Itā€™s as simple or as complex as you want it to be. Any tutorials for tile-based dungeons you find for other engines should also apply to Defold. You can change tilemaps dynamically however you want, you justā€¦tilemap.set_tile(). The only weird part with Defold is that you have to pre-set some tiles in the corners since it pre-allocates the bounds of the tilemap.

5 Likes

Yeah that was my concernā€¦ I may have some characters that will be big enough to be displayed behind AND in front of the ā€œtop piecesā€ mentioned above, but I can still change my mind.

If it appears to create a huge constraint (for a small benefit), Iā€™ll give up the idea.

I suppose it doesnā€™t mean that I wonā€™t be able to create ā€œinfiniteā€ tilemaps? (even if the bounds are pre-allocated, I can dynamically increase the tilemap ā€œinside the boundsā€?)

I created a topic to shortly describe my use case, do you think you could take a quick look at it?

For now, my problem is more about how to create ā€œsub-tilemapā€ (??) templates? (not even sure of what Iā€™m talking about)

Anyway thanks of your answer, Iā€™ll take a deeper look at everything available here and there about dungeon generation.

1 Like

It doesnā€™t make much sense to create a tilemap of infinite size. I would suggest that you use a number of smaller tilemaps as the segments/chunks of the map nearest the player and update those as the player moves around on the map. I have an example similar to this here: https://github.com/britzl/publicexamples/tree/master/examples/infinite_map

2 Likes