The best way to do this depends on how many different heights you need.
- For very few different heights, I think your second approach will work fine
- If you need a lot of heights(> 5 or something) you might want to do it like this:
- create one alternative tile for each possible height (with TileSetAtlasSource.create_alternative_tile)
- set the offset of all the alternative tiles to
-height, with height in pixels - for each tile you place, choose the alternative tile corresponding to its height
- In the niche scenario that a) you exceed the limit of 4096 alternative tiles or b) creating alternative tiles becomes to performance-heavy, you could theoretically do what I ended up doing for my project and modify the engine source. I can show you how I did it but I really don’t recommend this way unless absolutely necessary and you’d need to write C++
- @dragonforge-dev suggested this as a solution to a somewhat related problem of mine; I just haven’t fully tested it out myself so I can neither recommend it nor advise against it:
Note that both 2. and 3. only work with TileSetAtlasSource, if you’re using TileSetScenesCollectionSource I think you’re either going to have to set the offset manually in a class that all tiles inherit, or resort to option 1. Like this:
class_name SceneTile
extends Sprite2D # or any other class with an offset property
var height: int = 0
func set_height(value: int) -> void:
height = value
offset = Vector2(0, -value)