VisibilityEnabler2D

Inherits: VisibilityNotifier2D < Node2D < CanvasItem < Node < Object

Enables certain nodes only when approximately visible.

Description

The VisibilityEnabler2D will disable RigidBody2D, AnimationPlayer, and other nodes when they are not visible. It will only affect nodes with the same root node as the VisibilityEnabler2D, and the root node itself.

If you just want to receive notifications, use VisibilityNotifier2D instead.

Note: For performance reasons, VisibilityEnabler2D uses an approximate heuristic with precision determined by ProjectSettings.world/2d/cell_size. If you need precise visibility checking, use another method such as adding an Area2D node as a child of a Camera2D node.

Note: VisibilityEnabler2D will not affect nodes added after scene initialization.

Properties

bool

freeze_bodies

true

bool

pause_animated_sprites

true

bool

pause_animations

true

bool

pause_particles

true

bool

physics_process_parent

false

bool

process_parent

false

Methods

bool

is_enabler_enabled ( Enabler enabler ) const

void

set_enabler ( Enabler enabler, bool enabled )


Enumerations

enum Enabler:

Enabler ENABLER_PAUSE_ANIMATIONS = 0

This enabler will pause AnimationPlayer nodes.

Enabler ENABLER_FREEZE_BODIES = 1

This enabler will freeze RigidBody2D nodes.

Enabler ENABLER_PAUSE_PARTICLES = 2

This enabler will stop Particles2D nodes.

Enabler ENABLER_PARENT_PROCESS = 3

This enabler will stop the parent's Node._process function.

Enabler ENABLER_PARENT_PHYSICS_PROCESS = 4

This enabler will stop the parent's Node._physics_process function.

Enabler ENABLER_PAUSE_ANIMATED_SPRITES = 5

This enabler will stop AnimatedSprite nodes animations.

Enabler ENABLER_MAX = 6

Represents the size of the Enabler enum.


Property Descriptions

bool freeze_bodies = true

If true, RigidBody2D nodes will be paused.


bool pause_animated_sprites = true

If true, AnimatedSprite nodes will be paused.


bool pause_animations = true

If true, AnimationPlayer nodes will be paused.


bool pause_particles = true

If true, Particles2D nodes will be paused.


bool physics_process_parent = false

If true, the parent's Node._physics_process will be stopped.


bool process_parent = false

If true, the parent's Node._process will be stopped.


Method Descriptions

bool is_enabler_enabled ( Enabler enabler ) const

Returns whether the enabler identified by given Enabler constant is active.


void set_enabler ( Enabler enabler, bool enabled )

Sets active state of the enabler identified by given Enabler constant.