What is VisibilityEnabler node and how to use it?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By unfa
:warning: Old Version Published before Godot 3 was released.

Looks like something that it used to optimize performance in 3D games, but how does it work, and how it should be used?

:bust_in_silhouette: Reply From: kubecz3k

Thanks to VisibilityEnabler you can pause animations and freeze physics as well as get information that given object just entered/exited the screen.

To use VisibilityEnabler you need to add it as a child to any spatial node.

You will be able to define concrete size for this enabler from the editor (violet box that you can resize inside the editor), or from the code via set_aabb.

You will be able to use checkboxes (Pause animations | Freeze Bodies) as well.

But usually the main reason to use Visibility Enabler node is to use it’s signals, there are couple interesting signals that you can use:

  • enter_screen
  • exit_screen
  • enter_camera
  • exit_camera

Usually I’m using enter_screen and exit_screen to turn on/off processing of a script (basically set_process(true/false))

is there any specific advantage in using visibilityenabler instead of visibilitynotifier? the signals seem to be the same and you can control set_process on both.

If pause animations or freeze bodies dont matter, are there any special differences between both?

Nuno Donato | 2017-04-18 10:37