Rotating things on object layer changes XY coordinates

When rotating objects on an object layer, the X and Y position will change. It looks like everything has a middle anchor, so the position shouldn’t change on rotation. It makes placing objects with varied rotations very frustrating.

1 Like

In fact, the position is changing because the rotation origin matches the origin of the object, which is in the top-left for rectangles and botton-left for tile objects. So when the rotation tool is used to rotate an object around its center, it is necessary to change its position. At the moment Tiled does not support changing the origin of the objects.

But I do not understand why this makes placing objects with varied rotations frustrating. In the end it should not matter at all where Tiled puts the origin, since it can be relatively easily moved to somewhere else when loading the map. I’ve tried to explain one approach to this at http://forum.mapeditor.org/t/deer-need-for-x-and-y-to-be-the-center-of-the-object-instead-of-top-left-corner/150. Does that help you?

Why do objects pivot based on the center inside of tiled then? Doesn’t it make more sense to put the pivot at the actual origin of the object?

1 Like

This would be very annoying, right? Also, what would you do in case of multiple selected objects then? Right now, it rotates around their collective visual center.

Hi Bjorn and Jermccurdy,

I have, maybe silly, question. I am on Ubuntu and have Tiled version 0.9.1 and I cannot find where is functionality for rotating objects under object layer…

thanks,
Piotr

I think the question is not silly, but the answer is simple. Support for object rotation was added in Tiled 0.10. To upgrade to a more recent version of Tiled on Ubuntu I recommend using the daily builds available from Tiled packages : “mapeditor.org” team. In short:

sudo add-apt-repository ppa:mapeditor.org/tiled
sudo apt-get update
sudo apt-get install tiled-daily

Hi Bjorn,

wow… looks amazing

I used Ubuntu Software Center, so that is reason why I did not get it.

Thanks for help !

I’m glad you like it. :-)

How did you make the quick screen capture?

I am using two tools.

Fist is video screen capture Kazam, this is my second or third screen capture program and finally this is best for me. It does quite nice compression without any digging in settings.

Then I am loading screencast to QGifer and make gif, there are some nice options like add margins or width and height outputted gif.

both free on Linux :).

I played around with this a bit and it seems really nice indeed. One day I will use it!

Do you think that this bug will be fixed soon? I’m not sure if I really want to handle the shifted anchor point within my game code or wait for a fix.

@Sebastian If you mean the anchor point being top-left for rectangle objects but bottom-left for tile objects, that’s unfortunately just the way it is and it’s not a bug pending to be fixed.

It can be made consistent eventually, but this will be a change in the map format affecting everyone using Tiled. That means, such a change would make it possible to define the anchor point explicitly, while the default behavior would need to stay the same.

I see, thx for quick response @bjorn!

Oh god why.

Im very bad at trigonometry. After 3 hours I finally found out the algorithm to find the center:

Vector pos = new Vector(x+ ((sin(radians(rot)) + cos(radians(rot))) * height/2f),y+ ((sin(radians(rot)) - cos(radians(rot))) * height/2f));

ps. Does someone know the math behind this? I though that a simple sin/cos would suffice, but that was not the case.

It makes sense to place objects using their center as their origin for games that use physics. I don’t think I ever seen a physics engine not use object’s centers for their origin.

You can add a map setting to use the object’s center for origin, just like all other map settings that already exist.
This would keep compatibility with older maps while allowing people to optionally use this feature so they wouldn’t have to re-calculate the object’s origin.

Yeah, that’s basically how it would be done. Though I think some people will need the option to override the origin per object anyway. Also, using the center for polygons and polylines will be problematic since it would change while editing the polygon. But those objects don’t use “width” and “height” properties anyway.

Adding support for centered anchor points is covered by the following issue: