Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tileMap layer shows wrong position in editor #88103

Closed
jonSP12 opened this issue Feb 8, 2024 · 5 comments · Fixed by #88157
Closed

tileMap layer shows wrong position in editor #88103

jonSP12 opened this issue Feb 8, 2024 · 5 comments · Fixed by #88157

Comments

@jonSP12
Copy link

jonSP12 commented Feb 8, 2024

Tested versions

4.3 dev 3

System information

windows 10 vulkan foward+

Issue description

layer shows in wrong position in editor

Steps to reproduce

  • add tileMap node
  • draw some tiles
  • add a new layer ( right menu add element )
  • draw some tile
  • bring that layer to the top so it shows behind

err10
_

err11

Minimal reproduction project (MRP)

NA

@RoyBerube
Copy link
Contributor

Try changing the Z index. The example show both set to 0.

@jonSP12
Copy link
Author

jonSP12 commented Feb 9, 2024

Try changing the Z index. The example show both set to 0.

but, thats something very easy to do for anyone running dev3... why do i have to do it ?
Plus the bug its not a big deal, someone just forgot something somewere... Will it stay there forever ? Probably a few months or more...lol, i dont know.

@RoyBerube
Copy link
Contributor

Look in the inspector for each tilemap. The setting for Z index is there. You can change it.

The order of the layers in the inspector does not affect draw order. Godot does not draw layers the same way as Photoshop where the order of the layer determines the draw order.

In Godot when two or more layers are on the same Z index, it is essentially random whether one gets drawn before the other. Change the Z index to control the draw order.

Kindly close the issue if that makes sense and your project starts to behave.

@kleonc
Copy link
Member

kleonc commented Feb 9, 2024

The order of the layers in the inspector does not affect draw order. Godot does not draw layers the same way as Photoshop where the order of the layer determines the draw order.

In Godot when two or more layers are on the same Z index, it is essentially random whether one gets drawn before the other. Change the Z index to control the draw order.

@RoyBerube This is false, the draw order of non-y-sorted layers with the same z-index should be the same as within the inspector. Please don't spread misinformation. If it doesn't work like that in some cases then it's a bug (please report such cases if they're not reported yet). By design they should be rendered according to the layer order (for the same z-index and no y-sorting).

Plus the bug its not a big deal, someone just forgot something somewere... Will it stay there forever ? Probably a few months or more...lol, i dont know.

@jonSP12 Currently there's an ongoing process of moving TileMap layers to individual Nodes (this proposal is being implemented). Some initial work for this is already included in 4.3.dev3, this bug is very likely caused by this. So some TileMap related regressions are expected to happen because of the mentioned ongoing rework, but they will surely be checked/addressed before the 4.3.stable (currently 4.3 is still in dev stage, there will be more focus on bugfixing in beta/rc stages, after the feature-freeze).
Thanks for reporting this!


Back to the issue: confirmed it's working correctly in v4.3.dev2.official [3524346], this is a regression. Happens on runtime too (not an editor-only issue).
E.g. this example script shows that child TileMapLayers are not being swapped for the first move_layer(1, 0) call:

extends TileMap

var swap_count := 0
func _input(event: InputEvent) -> void:
	if event.is_action_pressed("ui_accept"):
		swap_count += 1
		print("Swap %s" % [swap_count])
		print_layers()
		move_layer(1, 0)
		print("move_layer(1, 0)")
		print_layers()
		print("-".repeat(80))

func print_layers() -> void:
	var layer_names := []
	for i in get_layers_count():
		layer_names.push_back(get_layer_name(i))
	print("Layer names: %s" % [layer_names])
	print("Children: %s" % [get_children()])

Output v4.3.dev.custom_build [94dbf69]:

Swap 1
Layer names: ["Layer0", "Layer1"]
Children: [Layer0:<TileMapLayer#24712840392>, Layer1:<TileMapLayer#24746394898>]
move_layer(1, 0)
Layer names: ["Layer1", "Layer0"]
Children: [Layer0:<TileMapLayer#24712840392>, Layer1:<TileMapLayer#24746394898>] <--- WERE NOT SWAPPED
--------------------------------------------------------------------------------
Swap 2
Layer names: ["Layer1", "Layer0"]
Children: [Layer0:<TileMapLayer#24712840392>, Layer1:<TileMapLayer#24746394898>]
move_layer(1, 0)
Layer names: ["Layer0", "Layer1"]
Children: [Layer1:<TileMapLayer#24746394898>, Layer0:<TileMapLayer#24712840392>]
--------------------------------------------------------------------------------
Swap 3
Layer names: ["Layer0", "Layer1"]
Children: [Layer1:<TileMapLayer#24746394898>, Layer0:<TileMapLayer#24712840392>]
move_layer(1, 0)
Layer names: ["Layer1", "Layer0"]
Children: [Layer0:<TileMapLayer#24712840392>, Layer1:<TileMapLayer#24746394898>]
--------------------------------------------------------------------------------

@jonSP12
Copy link
Author

jonSP12 commented Feb 9, 2024

Currently there's an ongoing process of moving TileMap layers to individual Nodes

I know :D ... Someone probably forgot to put it the way it was before, or didnt bothered since they are being moved to tree nodes. They will probably be moved up and down like 2d sprites on the tree. ( the bug is not a big deal... )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants