Can I force a Camera2D to stay in its limit?

Godot Version

4.2.2

Question

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.

3 Likes

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

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.