I want to be able to rotate a rectangle using another rectangles origin
So I thought I would have to do this:
rect2.setOrigin(rect1.getOrgin());
But that made rect2 rotate differently.
Any help?
All transformations are applied relative to the origin. If you set the origin to the top left corner (default) your rectangle shape will rotate around the top left corner. If you set the origin to the middle of the rectangle shape it will rotate around its center.
As such the origin is local to an object and if you "copy" the origin of another rectangle shape, you'll just copy the local origin. If you want to rotate around another object, you need to use the global position instead:
rect2.setOrigin(rect.getPosition());
All transformations are applied relative to the origin. If you set the origin to the top left corner (default) your rectangle shape will rotate around the top left corner. If you set the origin to the middle of the rectangle shape it will rotate around its center.
As such the origin is local to an object and if you "copy" the origin of another rectangle shape, you'll just copy the local origin. If you want to rotate around another object, you need to use the global position instead:
rect2.setOrigin(rect.getPosition));
This did work but it sets rect2 far from the rect1
If I try to move it closer to rect1 also moves rects2 orgin