I have been looking at this for the past hour and im unsure if i can integrate it to my code, all i have to do is change the limits while tweening them out, which is what i tried beforehand, the screen camera as is, is the following:
func _on_RoomDetector_area_entered(area):
var collision_shape = area.get_node("CollisionShape2D")
var size = collision_shape.shape.extents*2
var view_size = get_viewport_rect().size
if size.y < view_size.y:
size.y = view_size.y
if size.x < view_size.x:
size.x = view_size.x
var cam = $Camera2D
var tween = $Camera2D/Tween
# this is the old camera code that only sets the value
# cam.limit_top = collision_shape.global_position.y - size.y/2
# cam.limit_left = collision_shape.global_position.x - size.x/2
# cam.limit_bottom = cam.limit_top + size.y
# cam.limit_right = cam.limit_left + size.x
# This is the new one that doesnt function well
tween.interpolate_property(cam, "limit_top", cam.limit_top, collision_shape.global_position.y - size.y/2, 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.interpolate_property(cam, "limit_left", cam.limit_left, collision_shape.global_position.x - size.x/2, 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.interpolate_property(cam, "limit_bottom", cam.limit_bottom, cam.limit_top + size.y, 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.interpolate_property(cam, "limit_right", cam.limit_right, cam.limit_left + size.x, 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start()
UPDATE: It seems that the top and the left side limits work just fine, the problem is the bottom and the right side limits, the bottom limit is very inconsistent, while enabling right always breaks it in a way, also, enabling the code makes the camera have a stroke for a few seconds but then it readjusts itself after 1-2 seconds