godotengine / godot

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

Tileset Editor does not support shape transforms #32901

Open noidexe opened 4 years ago

noidexe commented 4 years ago

Godot version: 3.2 alpha 2

OS/device including version: Windows 10 64 bits

Issue description: Convert to TileSet generates incorrect collision shapes when sprites have centered set to true. It seems to just take the polygon property inside the CollisionPolygon2D and use those values to generate the collider. image

Disabling centered and manually redrawing the polygon will generate the correct collision shape when converting to tileset. image

Steps to reproduce:

Minimal reproduction project: https://github.com/godotengine/godot-demo-projects/tree/master/2d/platformer

SpechtMagnus commented 4 years ago

This bug only seems to impact the tileset editor. When actually using the tileset in a tilemap all collisions are at the correct location

SpechtMagnus commented 4 years ago

The problem here seems to be, that the tileset editor plugin ignores the transform property of the collision shape completely while "export to tileset" uses it to position the shape. This leads to problems when you want to edit a tileset that was created by the latter. I see two solutions that would not break compatibility with existing tilesets:

  1. Rewrite the tileset editor plugin so that it handles an additional transform property for selected polygons
  2. Rewrite the tileset editor so that it converts between an absolute coordinate system and a coordinate system relative to the transform every time it reads and writes tileset collision polygons.

I would personally prefer the first option as it's a lot cleaner and less hacky even though it comes with quite some code changes. The second one would be easier to implement but might lead to problems in the future.

Any thoughts?

noidexe commented 4 years ago

Yeah I think option 1 would be the best. .tres files are text based and can be edited and generated by scripts. I wouldn't want the editor plugin modifying what was a valid format until now and converting and reconverting on read and write all the time does feel hacky.

Lunarexxy commented 3 years ago

Still an issue in Godot 3.2.3.stable, on Windows 10 64-bit.

For anyone who tries to fix it in the future, the centered: true issue also affects Navigation and Occlusion polygons.

Godot_v3 2 3-stable_win64_2020-10-11_17-11-14

(the title change may have been meant to reflect that, but I wanted to make sure it was specifically mentioned)

You can still work around it by disabling centered on the sprite and redrawing the polygons before converting.