Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | ferranferri |
Hi, I’m trying to programmatically create an isometric scene. When I paint the scene I get this:
Painting the scene
Seems that layers sort y with themselves but not with the rest of the tilemap.
This is the code:
public override void _Ready()
{
_packedScene = ResourceLoader.Load<PackedScene>("res://data/TerrainTileMap.tscn");
var tm1 = _packedScene.Instantiate<TileMap>();
tm1.SetLayerYSortEnabled(0, true);
tm1.SetCell(0, new Vector2i(5,5), 0, new Vector2i(1,0), 0);
tm1.SetCell(0, new Vector2i(5,6), 0, new Vector2i(1,0), 0);
tm1.SetCell(0, new Vector2i(5,7), 0, new Vector2i(1,0), 0);
for (var i = 8; i < 20; i++)
{
tm1.SetCell(0, new Vector2i(5,i), 0, new Vector2i(1,0), 0);
}
tm1.AddLayer(1);
tm1.SetLayerYSortEnabled(1, true);
tm1.SetLayerModulate(1, Colors.Aqua);
tm1.SetCell(1, new Vector2i(5,11), 0, new Vector2i(1,0), 0);
AddChild(tm1); }
So how to use Y sorting using the whole tilemap? Or it’s simply that I’m not using layers properly?
Hi, I just want to confirm: You want all elements in the TileMap on any layer be y_sorted with each other?
E.g. if I have a tile with y-value 0 and one with 2 on layer 1 and a tile with y-value 1 on layer 2 then it should be between both of them?
From the documentation TileMap — Godot Engine (latest) documentation in English
I understand that the y-sort should only work on your current layer, not all of them.
Therefore I think that you would need to move all objects you want to y-sort into one layer.
ipdramon | 2022-11-29 18:44
Well, to give some context, what I want to do is to highlight some tiles by coloring them (for UI/UX purposes). As you can not modulate a single tile, I decided to simply paint a second layer with the highlighted tiles. But the Y-sort of the layer only seems to work on the layer and not in the whole tilemap. If there is an alternative method to color a single tile, that can be a solution for me.
ferranferri | 2022-11-29 23:31
Are the tilemaps a child of YSort node?
exuin | 2022-12-11 21:42
Ysort is not a node in Godot 4.
ferranferri | 2022-12-12 16:08
y-sort is different in godot 4 than godot 3
rossunger | 2022-12-19 02:03