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?

in Engine by (268 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 !

by (184 points)
selected by

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.