From 7746afec94cd28820cfa35791af92bd66361df5f Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Tue, 27 Oct 2020 17:35:41 +0100 Subject: [PATCH] Document hiding a Control when its reference point is behind the camera See https://github.com/godotengine/godot/issues/1725. (cherry picked from commit b3a6937c0c36fcca761d4c18a6d711bdb24a967e) --- doc/classes/Camera.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/classes/Camera.xml b/doc/classes/Camera.xml index 105b39e73f8..4d91a8744e5 100644 --- a/doc/classes/Camera.xml +++ b/doc/classes/Camera.xml @@ -163,6 +163,13 @@ Returns the 2D coordinate in the [Viewport] rectangle that maps to the given 3D point in worldspace. + [b]Note:[/b] When using this to position GUI elements over a 3D viewport, use [method is_position_behind] to prevent them from appearing if the 3D point is behind the camera: + [codeblock] + # This code block is part of a script that inherits from Spatial. + # `control` is a reference to a node inheriting from Control. + control.visible = not get_viewport().get_camera().is_position_behind(global_transform.origin) + control.rect_position = get_viewport().get_camera().unproject_position(global_transform.origin) + [/codeblock]