godot: Camera2D limits doesn't work well if limit_smoothed is enabled
Godot version
3.4.2 stable
System information
Windows 10, GLES2, Intel HD Graphics 610
Issue description
Since godot version 3.4.1 the camera limits stop working properly if limit_smoothed
is enabled, while in previous versions it never gave problems. When starting the scene, you notice a movement of the camera as if it was being moved:
And sometimes when setting certain limits, the camera moves slightly.
In 3.3.3 works fine:
But this happens with 3.4.1 and 3.4.2
Steps to reproduce
Enable limit_smoothed
and smoothing_enabled
to true
on Camera2D.
Minimal reproduction project
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 22 (16 by maintainers)
@dannygaray60 Yes, this is the expected behaviour. If you change the camera position and you don’t want it to scroll to the new position, then you call
reset_smoothing()
; exactly as you’re doing.Note: If, as you suggest, you make the
Camera2D
a child of your player or you simple place theCamera2D
where you want it to start, then it enters theSceneTree
at theglobal_position
as defined in theInspector
. Since there is no change in position, there will be no scrolling, because there is nowhere to scroll from. When you set the position in_ready()
(and don’t usereset_smoothing()
it scrolls from the position defined in theInspector
.You are right in that this fix should be included in the release notes; since you’re probably not the only one that’s used to the previous broken behaviour.
Just as an aside, I don’t know whether it’s related, I haven’t really been following this topic, but just to mention that in this functionality:
c
is not capped to 1.0. i.e. c can end up being larger than one at low frame rates / tick rates with large smoothing values, which looks like it would cause oscillations. Low frame rates might be seen especially at startup.We can’t rename methods anymore throughout 4.x, now that 4.0 is in release candidate stage.
@dannygaray60 This is the expected behaviour. It was a bug that the camera did not scroll smoothly to its new position. If you want the camera to immediately snap to the position and not move there smoothly, you need to call
reset_smoothing()
. With #63083, callingreset_smoothing()
after adjusting the camera properties in_ready()
now works correctly. If not, please let me know and provide a new MRP.Note: #63330 captures some of the remaining bugs with
limit_smoothed
disabled and setting the camera properties in_ready()
.Regardless of what is done further, for now this should be documented.
So it looks like the prescription (for now at least) would be to call them in a specific order (first reset, then force update), rather than calling one or the other or force → reset.
Might be worth considering whether we should A) take the suggestion you mentioned (update then fix camera pos then update again), B) document this specific way of doing it, or C) have a new method specifically for forcing a camera into its limits immediately with no smoothing… or, D) another suggestion I haven’t thought of.
As calling
force_update_scroll()
right before callingreset_smoothing()
was giving the intended behavior in #50807, therefore_update_scroll()
was made to be executed first. In the case which is mentioned in this issue, the camera is already at it’s limit(top and bottom). The issue is getting resolved by callingreset_smoothing()
twice because in this case_update_scroll()
needs to be executed after settingsmoothed_camera_pos
or this can also be achieved by callingforce_update_scroll()
afterreset_smoothing()
.https://user-images.githubusercontent.com/79760854/148373873-2ea9c712-626f-4f17-a655-c0f8388f0089.mp4
May be we need to call
_update_scroll()
both before and after settingsmoothed_camera_pos
in thereset_smoothing()
method, sorry if it sounds weird.