godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.61k stars 21.1k forks source link

TileMap: Unexpected offset when painting multiple tiles #76935

Open timothyqiu opened 1 year ago

timothyqiu commented 1 year ago

Godot version

4.0.2.stable

System information

Arch Linux

Issue description

I have two tiles:

image

When painting both of them in the editor (Shift select both of them), I expect them to be painted as shown in TileSet/TileMap dock, but the blue one has an unexpected offset.

image

I understand that the blue tile is actually located at (64, 0), but the behavior is counterintuitive.

Steps to reproduce

  1. Use the MRP.
  2. Select both tiles in the TileMap dock and paint them in the editor.

Minimal reproduction project

test-4.zip

groud commented 1 year ago

This is not a bug. The algorithm tries to keep the same tile layout from the atlas to the world, but there's no simple way to map an atlas coordinate to a tilemap coordinates. The current solution always use the top-left corner as it is the simplest way to implement it. It could be improved to find the most adequate origin tile though, but keep it mind this would not work with isometric or hexagonal shapes.

I feel that a better solution could be implemented, but I am not sure it is simple to do. Whoever wants to implement it is welcome to try though !