Document hiding a Control when its reference point is behind the camera

See https://github.com/godotengine/godot/issues/1725.

(cherry picked from commit b3a6937c0c)
This commit is contained in:
Hugo Locurcio 2020-10-27 17:35:41 +01:00 committed by Rémi Verschelde
parent 638e24684f
commit 7746afec94
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -163,6 +163,13 @@
</argument> </argument>
<description> <description>
Returns the 2D coordinate in the [Viewport] rectangle that maps to the given 3D point in worldspace. 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]
</description> </description>
</method> </method>
</methods> </methods>