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: set_cellv(map_point, -1) does not work with Ysort #38297

Open
Tracked by #45334
golddotasksquestions opened this issue Apr 28, 2020 · 1 comment
Open
Tracked by #45334

Comments

@golddotasksquestions
Copy link

golddotasksquestions commented Apr 28, 2020

Godot version: 3.2.1

OS/device including version: Wine64

Issue description:
ysort_set_tile_bug

If the Tilemap in question has the ysort property enabled, only the first tile will be set to -1.
As soon as ysort is disabled, set_cellv works as expected.
In fact, the Tilemap does not seem to ever leave the Area2D of the player, even tough it should when moving from tile to tile. So this might be an Area issue too.

Player Code:

func _on_Area2D_body_entered(body):
	if "yellow_tile" in body.name:
		$Label.text = "is in tile"
		yellow_tile = body
		var map_point = yellow_tile.world_to_map(global_position + Vector2(16,16)) #-16,-16 = yellowtile position
		yellow_tile.set_cellv(map_point, -1, false, true)
		yellow_tile.call_deferred("update_dirty_quadrants")

Thanks to user Grandro on Discord who has figured this out!

Steps to reproduce:
Move player on a Tilemap tile.

Minimal reproduction project:
Grid_set_tile_ysort_bug.zip

@bojidar-bg
Copy link
Contributor

Changing the player code to this works around the issue:

func _on_Area2D_body_entered(body):
	if "yellow_tile" in body.name:
		$Label.text = "is in tile"
		yellow_tile = body
		var map_point = yellow_tile.world_to_map(global_position + Vector2(16,16)) #-16,-16 = yellowtile position
		yellow_tile.call_deferred("set_cellv", map_point, -1)

Seems like the problem is that the body the Area2D has been detecting vanishes too soon, so it doesn't report it as exiting.

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

No branches or pull requests

2 participants