Stopping Camera With Area 2D's

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lincolnpepper

I want to be able to stop the camera scrolling in different places in different parts of the level. My idea for how to implement this is to overlay an Area2D over the camera viewport and use Area2D’s for where i don’t want the camera to enter. When they collide, get the side it collided on and set the proper limit attribute to the camera’s X or Y position. But this seems janky and slow to me, and i feel like there is a better solution. But i can’t come up with anything. What do you think?

:bust_in_silhouette: Reply From: Suleymanov

Try if $Camera2D.distance_to(#anArea.position) < #desiredDistance: then stop camera movement.