Quick answer: Camera2D limits clamp the screen rect, not the camera center. If the viewport is wider than your limit rect, the camera shows beyond the limits. Either zoom in, expand the world art, or use drag margins.
A room is sized 640×360 with Camera2D limits set to match. The viewport at zoom 1 is 1280×720. The camera shows half a screen of empty space on either side of the room — the limits don’t seem to clamp tightly.
Limits Clamp Edges, Not Center
The camera tries to keep its visible rectangle inside the limit rectangle. When the visible rectangle is larger than the limit rectangle, the math has no valid placement, so Godot centers the camera and ignores the limits along that axis. You see beyond the limits because the math can’t honor them.
This is intentional but surprising. The fix depends on what you actually want.
Option 1: Zoom In
$Camera2D.zoom = Vector2(2, 2) # 2x = viewport sees half the size
At zoom 2, the viewport effectively shows 640×360 of world space — matching the room exactly. Limits now bound the camera tightly.
Option 2: Expand the Room
Extend the world art (or a backdrop) beyond the limit rect. The camera still shows beyond the limits at low zoom, but what it shows isn’t empty.
Option 3: Drag Margins
Drag margins (drag_horizontal_offset, drag_vertical_offset) keep the camera at a fixed offset from the player so the player has visible space ahead of them. Used right, they ensure the camera doesn’t reach the limit edges in typical play.
$Camera2D.drag_horizontal_enabled = true
$Camera2D.drag_left_margin = 0.2
$Camera2D.drag_right_margin = 0.2
The player can wander 20% from center before the camera follows — soft “dead zone” that keeps gameplay focused.
Runtime Limit Changes
For metroidvania-style room transitions:
$Camera2D.limit_left = current_room.position.x
$Camera2D.limit_top = current_room.position.y
$Camera2D.limit_right = current_room.position.x + current_room.size.x
$Camera2D.limit_bottom = current_room.position.y + current_room.size.y
$Camera2D.limit_smoothed = true # smooth transition
The camera animates from the old limits to the new ones over the next several frames rather than snapping.
Verifying
Draw a debug rectangle at the limit bounds. Move the player toward each edge. The camera should stop with its visible edge aligned to the corresponding limit (provided viewport fits). If you see beyond, your viewport exceeds limits along that axis.
“Camera2D limits clamp the visible rectangle. If your rectangle is bigger than the limits, the camera can’t honor them — zoom in or expand the world.”
For pixel-art games, design rooms as a multiple of your zoomed viewport size — clean fits without dead space.