Skip to content

LightInteraction ​

Inherits: SwitchInteraction < InteractableObjectInteraction < Interaction < Resource

Light interaction - extends SwitchInteraction to control lighting Creates Light3D node (OmniLight3D or SpotLight3D) at runtime

Properties ​

LightTypelight_typeLightType.OMNI
Colorlight_colorColor.WHITE
floatlight_energy1.0
floatlight_indirect_energy1.0
boolshadow_enabledfalse
floatshadow_bias0.1
floatshadow_normal_bias2.0
floatomni_range5.0
floatomni_attenuation1.0
OmniLight3D.ShadowModeomni_shadow_modeOmniLight3D.ShadowMode.SHADOW_CUBE
floatspot_range5.0
floatspot_attenuation1.0
floatspot_angle45.0
floatspot_angle_attenuation1.0
VFXSelectionlight_vfx

Variables ​

Light3Dlight_node
Node3Dvfx_instance

Methods ​

voidsetup_for_interactable_objects( interactable: InteractableObject )
voidset_switch_state( new_state: SwitchState, triggering_entity: Entity = null )
voidturn_on_light( triggering_entity: Entity = null )
voidturn_off_light( triggering_entity: Entity = null )
SwitchStateget_light_state()
boolis_light_on()
boolis_light_off()
voidbreak_light()
Light3Dget_light_node()
voidset_light_color( color: Color )
voidset_light_energy( energy: float )
voidset_light_range( range_value: float )
voidset_shadows_enabled( enabled: bool )
voidtoggle_shadows( enabled: bool )
Dictionarysave_state()
voidload_state( state: Dictionary )
voidcleanup()

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.