Camera panning with character

Godot Version

Godot 4

Question

I'm having trouble with parallax backgrounds and panning, I want the camera to keep the character in frame then stop when it reaches the end of the map. I have set limits and made the camera 2D a child node of character body 2D (basically I've tried everything the internet has told me). Every time I have run the game however it lags behind the character then stops about 576 pixels before the end of the map. The weird thing is it does what I want on the left side of the map but not the right. Any help on how to fix this would be greatly appreciated.

What values did you set the limit to?

You’re going to have to show us your code.

Alternately, you can use my Camera2D Plugin which allows you to just drop a Camera2DLimit component onto your Camera2D and assign your TileMapLayer to it, which will automatically limit your camera. Then add a CameraPan2D component which respects those boundaries and supports scrolling with mouse (through edge scrolling), keyboard, controller, and touch screen drag.

(I just finished finalizing the plugin and adding a Readme.)