Light ​
Inherits: Node3D
LightEffect manages light sources and associated audio effects in the game world. It provides functionality to control both OmniLight3D and SpotLight3D nodes, as well as an associated AudioStreamPlayer3D for ambient sound effects.
Description ​
Key features:
- Controls both OmniLight3D and SpotLight3D nodes
- Manages an associated audio stream for ambient effects
- Provides functionality to toggle shadows for performance optimization
- Can be enabled/disabled for interactive lighting systems
- Automatically adds itself to the "lights" group when entering the scene tree
Note: All instances of this class are automatically added to the "lights" group for proper scene organization and potential performance optimizations.
Properties ​
Light3D | omni_light | |
SpotLight3D | spot_light | |
AudioStreamPlayer3D | audio_stream_player_3d | |
bool | light_enabled | true |
bool | shadows_enabled | true |
bool | loop_audio | true |
Variables ​
float | stored_omni_energy | 1.0 |
float | stored_spot_energy | 1.0 |
bool | stored_omni_visible | true |
bool | stored_spot_visible | true |
Methods ​
void | start_audio() |
void | stop_audio() |
void | set_audio_volume( volume: float ) |
void | toggle_shadows( value: bool ) |
void | enable_shadows() |
void | disable_shadows() |
void | set_light_enabled( enabled: bool ) |
void | enable_light() |
void | disable_light() |
void | toggle_light() |
void | set_light_energy( energy: float ) |
void | set_light_color( color: Color ) |
void | set_omni_range( range_value: float ) |
void | set_spot_range( range_value: float ) |
void | set_spot_angle( angle_degrees: float ) |
void | animate_light_energy( target_energy: float, duration: float = 1.0 ) |
void | animate_light_color( target_color: Color, duration: float = 1.0 ) |
void | start_flicker_effect( min_energy: float = 0.5, max_energy: float = 1.5, interval: float = 0.1 ) |
void | stop_flicker_effect() |
bool | is_light_enabled() |
bool | are_shadows_enabled() |
bool | has_lights() |
bool | has_audio() |
Signals ​
light_turned_on() ​
Signal emitted when the light is turned on
light_turned_off() ​
Signal emitted when the light is turned off
shadows_toggled( enabled: bool ) ​
Signal emitted when shadows are toggled
Property descriptions ​
Light3D omni_light ​
Reference to the OmniLight3D node (if present)
SpotLight3D spot_light ​
Reference to the SpotLight3D node (if present)
AudioStreamPlayer3D audio_stream_player_3d ​
Reference to the AudioStreamPlayer3D for ambient sound effects
bool light_enabled = true ​
Whether the light is currently enabled
bool shadows_enabled = true ​
Whether shadows are enabled
bool loop_audio = true ​
Whether audio should loop continuously
Variable descriptions ​
float stored_omni_energy = 1.0 ​
The energy of the omni light, kept while it is switched off.
float stored_spot_energy = 1.0 ​
The energy of the spot light, kept while it is switched off.
bool stored_omni_visible = true ​
Whether the omni light was visible, kept while it is switched off.
bool stored_spot_visible = true ​
Whether the spot light was visible, kept while it is switched off.
Method descriptions ​
void start_audio() ​
Start playing the ambient audio
void stop_audio() ​
Stop playing the ambient audio
void set_audio_volume( volume: float ) ​
Set the audio volume (0.0 to 1.0)
void toggle_shadows( value: bool ) ​
Toggles shadow casting for both OmniLight3D and SpotLight3D (if present) This can be used for performance optimization by disabling shadows when not needed
void enable_shadows() ​
Enable shadows for all lights
void disable_shadows() ​
Disable shadows for all lights
void set_light_enabled( enabled: bool ) ​
Enable or disable the light effect
void enable_light() ​
Turn on the light effect
void disable_light() ​
Turn off the light effect
void toggle_light() ​
Toggle the light on/off
void set_light_energy( energy: float ) ​
Set the energy/brightness of all lights
void set_light_color( color: Color ) ​
Set the color of all lights
void set_omni_range( range_value: float ) ​
Set the range of omni light (if present)
void set_spot_range( range_value: float ) ​
Set the range of spot light (if present)
void set_spot_angle( angle_degrees: float ) ​
Set the spot light angle (if present)
void animate_light_energy( target_energy: float, duration: float = 1.0 ) ​
Animate light energy over time
void animate_light_color( target_color: Color, duration: float = 1.0 ) ​
Animate light color over time
void start_flicker_effect( min_energy: float = 0.5, max_energy: float = 1.5, interval: float = 0.1 ) ​
Flicker effect - randomly varies light energy
void stop_flicker_effect() ​
Stop flicker effect
bool is_light_enabled() ​
Check if the light is currently enabled
bool are_shadows_enabled() ​
Check if shadows are currently enabled
bool has_lights() ​
Check if any light components are present
bool has_audio() ​
Check if audio component is present