Skip to content

Commit

Permalink
Fix screen center position returned for rotated Camera2D
Browse files Browse the repository at this point in the history
  • Loading branch information
kleonc committed Oct 16, 2023
1 parent 9957f1a commit 836d80b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scene/2d/camera_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,16 @@ Transform2D Camera2D::get_camera_transform() {
screen_rect.position += offset;
}

camera_screen_center = screen_rect.get_center();

Transform2D xform;
xform.scale_basis(zoom_scale);
if (!ignore_rotation) {
xform.set_rotation(camera_angle);
}
xform.set_origin(screen_rect.position);

return (xform).affine_inverse();
camera_screen_center = xform.xform(0.5 * screen_size);

return xform.affine_inverse();
}

void Camera2D::_notification(int p_what) {
Expand Down

0 comments on commit 836d80b

Please sign in to comment.