Can I force a Camera2D to stay in its limit?

Godot Version



I am moving my camera by changing its position field according to the input. The problem is that whenever the camera crosses one of its limits, it still moves, even when the viewport doesn’t. That makes it so that when I try to cross back into the main scene it takes a while.
Is there a way to force the camera to now wander of boundaries, or maybe a better way to move it?

The best way is to probably clamp it’s x and y to the desired boundaries. If the boundaries are dynamic, you could get them from the size of your area.


So just manually remake the limit system of the camera?

Why not use the given limit system, you can set it in the camera properties, or do you want a different functionality?

I want the camera’s position to stay in the limit, not just what is viewed.

1 Like