How to define limits for Camera2D smooth follow?

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

I set smooth follow for Camera2D and it works good. When player moves, camera follows him with some offset. But in my game space ship can accelerate infinitely and I see that it slowly moves to the edge of screen.

So, is it possible to limit smooth following for Camera2D to keep player in some square at center of screen? Camera should not to increase distance between it and player if it has reached some maximum value. How to do it?

:bust_in_silhouette: Reply From: quizzcode

hey, not a pro here.
But, you cat set the smoothing to the camera in the script.

From what i remember :

	set_enable_follow_smoothing(false) #smooth or no smooth
set_follow_smoothing(4) #How much smoothing you want

So now that you know how to manage it… By getting the position of the ship you can update it.

have fun !

Hmmm. But how to get current smoothing value (how far my ship from the center of the screen) to set new smoothing value?

When I turn off smoothing in script does the camera jump to player position immmediately or smoothed?

Robotex | 2020-05-24 18:26