Godot Version
4.3.stabe.mono.official
Question
I have a simple setup with a Sprite2D and a child Camera2D.
Camera’s anchor mode is “drag center”.
When I run it, the sprite appears at the center of the screen, however, when I add margins to the camera, the starting point of the camera is such that the sprite is at the corner of the margin. How do I force it to start at the center?

extends AnimatedSprite2D
@export var map: Sprite2D
const speed = 170
func _ready() -> void:
var camera: Camera2D = $Camera2D
var size = Vector2(
map.texture.get_width(),
map.texture.get_height()
) * map.scale
position = size / 2.0
camera.limit_bottom = size.y
camera.limit_right = size.x
func _physics_process(delta: float) -> void:
if Input.is_action_pressed("up"):
position.y -= speed * delta
if Input.is_action_pressed("down"):
position.y += speed * delta
if Input.is_action_pressed("right"):
position.x += speed * delta
if Input.is_action_pressed("left"):
position.x -= speed * delta
func _process(delta: float) -> void:
pass