Repository: godotengine/godot (language: cpp)

Issue:
The doc of follow_viewport_enabled does the opposite thing.
**Version**

4.4.beta4

**Issue description:**
CanvasItem.follow_viewport_enabled 
The description does not match the actual behavior, in fact it does the opposite.

> "If enabled, the CanvasLayer stays in a fixed position on the screen. If disabled, the CanvasLayer maintains its position in world space."

The GUI nodes (those labels) is in a canvaslayer that DISABLED follow_viewport_enabled, whitch would be "maintains its position in world space" according to the doc.
But apparently these GUI only "fixed position on the screen", not maintain in wolrd space.

![Image](https://github.com/user-attachments/assets/7d30fd0c-843f-405e-a0be-4e74247cc85e)

begins of the camera movement
![Image](https://github.com/user-attachments/assets/5720eeeb-0028-42ed-b190-8fb944036237)

end of the camera movement
![Image](https://github.com/user-attachments/assets/03b86615-bac3-48bd-91f3-b874fffa8d63)


**MRP file:**
[CanvasLayerFviewTest.zip](https://github.com/user-attachments/files/18865420/CanvasLayerFviewTest.zip)


_Originally posted by @rt9391 in https://github.com/godotengine/godot/issues/99754#issuecomment-2668164294_
            


Discussion / hints:
I tested the provided MRP and looked at the Follow Viewport setting for the CanvasLayers, and from what I can tell this does indeed appear to be the case. For reference, the relevant code, from [line 296 of `canvas_layer.cpp`](https://github.com/godotengine/godot/blob/e567f49cbb292dd6bb628348e67c1f3c2a3a5f99/scene/main/canvas_layer.cpp#L296):
```cpp
void CanvasLayer::_update_follow_viewport(bool p_force_exit) {
	if (!is_inside_tree()) {
		return;
	}
	if (p_force_exit || !follow_viewport) {
		RS::get_singleton()->canvas_set_parent(canvas, RID(), 1.0);
	} else {
		RS::get_singleton()->canvas_set_parent(canvas, vp->get_world_2d()->get_canvas(), follow_viewport_scale);
	}
}
```
To my understanding:
- If "Follow Viewport" is `false`, then the CanvasLayer's rendering parent is some kind of null object (perhaps the root)? So it doesn't get affected by any world space movement.
- If "Follow Viewport" is `true`, then the CanvasLayer's rendering parent is the 2D world's canvas. So it *does* get affected by world space movement, such as moving off-screen as the camera moves.

I'd be happy to throw together a quick PR for this, unless you'd like to @rt9391 😄 
> I tested the provided MRP and looked at the Follow Viewport setting for the CanvasLayers, and from what I can tell this does indeed appear to be the case. For reference, the relevant code, from [line 296 of `canvas_layer.cpp`](https://github.com/godotengine/godot/blob/e567f49cbb292dd6bb628348e67c1f3c2a3a5f99/scene/main/canvas_layer.cpp#L296):
> 
> void CanvasLayer::_update_follow_viewport(bool p_force_exit) {
> 	if (!is_inside_tree()) {
> 		return;
> 	}
> 	if (p_force_exit || !follow_viewport) {
> 		RS::get_singleton()->canvas_set_parent(canvas, RID(), 1.0);
> 	} else {
> 		RS::get_singleton()->canvas_set_parent(canvas, vp->get_world_2d()->get_canvas(), follow_viewport_scale);
> 	}
> }
> To my understanding:
> 
> * If "Follow Viewport" is `false`, then the CanvasLayer's rendering parent is some kind of null object (perhaps the root)? So it doesn't get affected by any world space movement.
> * If "Follow Viewport" is `true`, then the CanvasLayer's rendering parent is the 2D world's canvas. So it _does_ get affected by world space movement, such as moving off-screen as the camera moves.
> 
> I'd be happy to throw together a quick PR for this, unless you'd like to [@rt9391](https://github.com/rt9391) 😄

Here`s the PR #103111 

Fix patch:
diff --git a/doc/classes/CanvasLayer.xml b/doc/classes/CanvasLayer.xml
index e542eb7aee44..03dce2ea387c 100644
--- a/doc/classes/CanvasLayer.xml
+++ b/doc/classes/CanvasLayer.xml
@@ -45,7 +45,7 @@
 			The custom [Viewport] node assigned to the [CanvasLayer]. If [code]null[/code], uses the default viewport instead.
 		</member>
 		<member name="follow_viewport_enabled" type="bool" setter="set_follow_viewport" getter="is_following_viewport" default="false">
-			If enabled, the [CanvasLayer] stays in a fixed position on the screen. If disabled, the [CanvasLayer] maintains its position in world space.
+			If enabled, the [CanvasLayer] maintains its position in world space. If disabled, the [CanvasLayer] stays in a fixed position on the screen.
 			Together with [member follow_viewport_scale], this can be used for a pseudo-3D effect.
 		</member>
 		<member name="follow_viewport_scale" type="float" setter="set_follow_viewport_scale" getter="get_follow_viewport_scale" default="1.0">


Test patch: