LightInteraction ​
Inherits: SwitchInteraction < InteractableObjectInteraction < Interaction < Resource
Light interaction - extends SwitchInteraction to control lighting Creates Light3D node (OmniLight3D or SpotLight3D) at runtime
Properties ​
LightType | light_type | LightType.OMNI |
Color | light_color | Color.WHITE |
float | light_energy | 1.0 |
float | light_indirect_energy | 1.0 |
bool | shadow_enabled | false |
float | shadow_bias | 0.1 |
float | shadow_normal_bias | 2.0 |
float | omni_range | 5.0 |
float | omni_attenuation | 1.0 |
OmniLight3D.ShadowMode | omni_shadow_mode | OmniLight3D.ShadowMode.SHADOW_CUBE |
float | spot_range | 5.0 |
float | spot_attenuation | 1.0 |
float | spot_angle | 45.0 |
float | spot_angle_attenuation | 1.0 |
VFXSelection | light_vfx |
Variables ​
Light3D | light_node | |
Node3D | vfx_instance |
Methods ​
void | setup_for_interactable_objects( interactable: InteractableObject ) |
void | set_switch_state( new_state: SwitchState, triggering_entity: Entity = null ) |
void | turn_on_light( triggering_entity: Entity = null ) |
void | turn_off_light( triggering_entity: Entity = null ) |
SwitchState | get_light_state() |
bool | is_light_on() |
bool | is_light_off() |
void | break_light() |
Light3D | get_light_node() |
void | set_light_color( color: Color ) |
void | set_light_energy( energy: float ) |
void | set_light_range( range_value: float ) |
void | set_shadows_enabled( enabled: bool ) |
void | toggle_shadows( enabled: bool ) |
Dictionary | save_state() |
void | load_state( state: Dictionary ) |
void | cleanup() |
Signals ​
light_turned_on( entity: Entity ) ​
Emitted when the light is turned on.
light_turned_off( entity: Entity ) ​
Emitted when the light is turned off.
light_state_changed( is_on: bool, entity: Entity ) ​
Emitted when the light changes: whether it is on, and who changed it.
Enumerations ​
enum LightType ​
The options of light type: omni, spot.
- OMNI =
0- OmniLight3D - emits in all directions - SPOT =
1- SpotLight3D - emits in cone shape
Property descriptions ​
Light Type
LightType light_type = LightType.OMNI ​
The kind of light (omni or spot).
Light Properties
Color light_color = Color.WHITE ​
Light color
float light_energy = 1.0 ​
Light energy/intensity multiplier
float light_indirect_energy = 1.0 ​
Indirect lighting multiplier (for GI)
bool shadow_enabled = false ​
Whether light casts shadows
float shadow_bias = 0.1 ​
Shadow bias (prevents shadow acne)
float shadow_normal_bias = 2.0 ​
Shadow normal bias
Omni Light Settings
float omni_range = 5.0 ​
Range of the omni light (only used if light_type is OMNI)
float omni_attenuation = 1.0 ​
Attenuation curve for omni light (2.0 = physically accurate)
OmniLight3D.ShadowMode omni_shadow_mode = OmniLight3D.ShadowMode.SHADOW_CUBE ​
Shadow mode for omni lights
Spot Light Settings
float spot_range = 5.0 ​
Range of the spot light (only used if light_type is SPOT)
float spot_attenuation = 1.0 ​
Attenuation curve for spot light (2.0 = physically accurate)
float spot_angle = 45.0 ​
Spotlight cone angle in degrees
float spot_angle_attenuation = 1.0 ​
Spotlight angular attenuation curve
Visual Effects
VFXSelection light_vfx ​
Optional VFX selection to play when light is on (sparks, particles, etc.)
Variable descriptions ​
Light3D light_node ​
The light that was made for the object.
Node3D vfx_instance ​
The visual effect that shows with the light.
Method descriptions ​
void setup_for_interactable_objects( interactable: InteractableObject ) ​
Sets up the switch and makes the light.
void set_switch_state( new_state: SwitchState, triggering_entity: Entity = null ) ​
Force the state: the light signals follow the switch signals
void turn_on_light( triggering_entity: Entity = null ) ​
Turn the light on
void turn_off_light( triggering_entity: Entity = null ) ​
Turn the light off
SwitchState get_light_state() ​
Get the current light state
bool is_light_on() ​
Check if light is currently on
bool is_light_off() ​
Check if light is currently off
void break_light() ​
Break the light (set to BROKEN state)
Light3D get_light_node() ​
Get the Light3D node (for advanced control)
void set_light_color( color: Color ) ​
Update light color at runtime
void set_light_energy( energy: float ) ​
Update light energy at runtime
void set_light_range( range_value: float ) ​
Update light range at runtime
void set_shadows_enabled( enabled: bool ) ​
Enable/disable shadows at runtime
void toggle_shadows( enabled: bool ) ​
Toggle shadows (for settings system integration)
Dictionary save_state() ​
The state of the light for a save (the switch and the light).
void load_state( state: Dictionary ) ​
Restores the light from a save.
void cleanup() ​
Removes the light and the visual effect.