0 votes

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?

asked May 18 in Engine by Robotex (110 points)

1 Answer

0 votes
Best answer

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 !

answered May 18 by quizzcode (152 points)
selected Jun 16 by Robotex

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?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.