Closed puppetmaster- closed 6 years ago
Could you provide an example project? A image is fine, but it's a bit light to really understand an issue...
the example project http://www.file-upload.net/download-11051501/Issue_1544.zip.html
Thanks, by checking your example project I was indeed able to reproduce the issue.
The "not_ok" subscene does not snap properly because it's a Node2D with a Polygon2D as a child, contrary to the "ok" subscene which is just a Polygon2D. The Node2D is by default represented by a selectable square of 64x64, so it does not match the 10x10 grid, but it snaps on the top left corner when instanced as a subscene. When Node2D is a main scene, it snaps properly from its center.
Actually no, the issue is simpler than that: Node2D simply always snaps at the top-left angle, regardless of whether it's an instanced scene, a root node or a child node. If you move the "issue_1544" node in the above example, the snapping will also be off.
So that's not really a bug per se, but more a consequence of the fixed 64x64 size of the Node2D "select box". To improve this, we'd need either to:
I can't explain it better :-) I prefer the second one. Node2D should snap on its origin by default.
If it helps, Node2D doesn't have a "size", or an area, like a Control or a Sprite does. It's just a position. So there's no "center".
On 17 November 2015 at 18:23, Rémi Verschelde notifications@github.com wrote:
Actually no, the issue is simpler than that: Node2D simply always snaps at the top-left angle, regardless of whether it's an instanced scene, a root node or a child node. If you move the "issue_1544" node in the above example, the snapping will also be off.
So that's not really a bug per se, but more a consequence of the fixed 64x64 size of the Node2D "select box". To improve this, we'd need either to:
- Make the size of the select box configurable, so that it can be adapted to the snap grid (e.g. 60x60 would work fine here)
- Make it possible to configure in a node that it should snap on its origin instead of its top-left corner. That would likely be the best solution, as it can also be desirable in some cases (e.g. have a 20x20 sprite snap properly from its center on a 16x16 tilemap).
— Reply to this email directly or view it on GitHub https://github.com/godotengine/godot/issues/1544#issuecomment-157511446.
But when you select it in the editor, it does have a "representation" of some sort, which is a 64x64 square and is affected by snapping. So it should indeed by default snap on its center/position instead of the top-left corner of what is just a visual helper.
Not only Node2D has this problem also position2d, particles2D, raycast2D and more. Light2D is OK in alpha 2.0
I think the whole snapping should work different, more similar to android studio or modern UI or 2D editors.. with autosnap with aligned elements, guides, etc. Let's do some research together on how to modernize this for 2.1 or later
This is related to #4255.
If I'm not wrong pivot is now implemented for almost all 2D nodes. We could use this pivot to snap nodes I think.
kicking to 3.1 as not urgent
@groud Did your 2D editor changes fix this?
Yeah, I think it did.