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

Custom origin points for Objects #3847

Open
eishiya opened this issue Nov 25, 2023 · 1 comment
Open

Custom origin points for Objects #3847

eishiya opened this issue Nov 25, 2023 · 1 comment
Labels
feature It's a feature, not a bug.

Comments

@eishiya
Copy link
Contributor

eishiya commented Nov 25, 2023

For the purposes of snapping, and for positioning things more generally in-engine, it would be helpful to be able to define an origin point on Objects. For example, in Tiled, Rectangle Objects have their origin point in the top left, but in sidescrolling games, it's common for entities, rectangles included, to be anchored somewhere near their bottom centre, and it would be nice to work in Tiled in a way that more closely represents the positions that one will be handling in the game logic. A more egregious example is Polygons/Polylines, which have their origin at the first point in the shape, which may have nothing to do with how the user may actually want the Object positioned.

There has been some discussion about this in #871, but that issue is about tile drawing offsets, and the discussion about solving the Tile Object positioning/snapping problem is only tangential. All types of objects can make use of a custom origin point, not just Tile objects. A per-Object origin would solve the Tile Object snapping difficulties mentioned in that issue and elsewhere.

This origin point should be relative to the default origin point, and should also serve as the rotation pivot - that's how things worked in engines/libraries I've worked with, at least.

UI

The origin could be displayed similarly to Point objects (a circled dot, always a fixed size on the screen), but perhaps at a lower opacity so it doesn't get in the way. It might be a good idea to only display the origin point for selected objects, since it's irrelevant when not modifying objects.
image

The point should default to 0,0 (i.e. at the default origin point). It should be displayed even in this case, so that it's easier for people to see what point the object's location corresponds to. This would be especially useful for Tile Objects, where their object alignment is a common source of confusion.

I think it would be fine if the only way to modify the origin point is by editing the origin x and origin y properties in the Properties panel. It would be cool to be able to drag and drop this point, but I doubt there are any free modifiers or free space in the UI left for that xP

When objects are resized, then the origin should be automatically updated to keep it in the same relative position, I think, as that seems more intuitive - this would be simpler to deal with if Tiled supported scaling rather than just resizing xP

Tile Object considerations

Tile Objects inherit many things from their Tile, and the Drawing Offset is taken into account. Since Tiles are often reused, I think it would make sense to let people define a Default Object Origin on the Tile, and to have Tile Objects inherit that by default. This should be separate from the Drawing Offset and the two should stack together; indeed in some cases one may want to set the Default Object Origin to the inverse of the Drawing Offset, allowing the tile to be positioned nicely with other tiles in a Tile Layer, while still behaving like just a normal screenspace rectangle when used as a Tile Object.

Bjorn has mentioned wanting to keep things simple and solve the Tile Object positioning problem with a single property that's somehow merged with the drawing offset, but I don't think that's a good approach, especially considering that Object origin isn't something that should be unique to Tile Objects. If all Objects have a customisable origin, then I think the idea of having both a Default Object Origin and a Drawing Offset is more palatable :]

Tilesets already have the Object Alignment property. If Default Object Origins are added, then I think these should be per-tile, and should be relative to the Object Alignment of the Tileset - that is, there is no need for per-tile Object Alignment, since Default Object Origin can take care of that. So, Tiles would just have a Drawing Offset that overrides the Tileset one, and a Default Object Origin that's relative to the Object Alignment point. I suspect many users using this feature would switch the Object Alignment to Top Left, for consistency with shape Objects, and then set an appropriate bottom-ish origin for each Tile that needs it.

It's acceptable for the origin points to not be displayed in the Tileset, but if possible, there should be some way to visualise them in the Tileset, especially since Tiled doesn't display your cursor coordinates within a tile.

@eishiya eishiya added the feature It's a feature, not a bug. label Nov 25, 2023
@ankisme
Copy link

ankisme commented Mar 19, 2024

Hope to add this feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature It's a feature, not a bug.
Projects
None yet
Development

No branches or pull requests

2 participants