Light
Light is a callable class that simplifies the process of spawning and configuring dynamic lights in Unreal Engine. It supports three light typesโPoint, Spot, and Rectโand automatically sets up location, rotation, color, intensity, attenuation, and shadow settings. The returned wrapper provides unified access to both the underlying light actor and its component, making it easy to manipulate lights in real time through Lua scripts.
/// tip
Light is an Actor so it inherits all functions from Actor
///
๐กย Light Profilesโ
/// note
- Point Lights act as a light bulb, casting light in all directions from a single point.
- Spot Lights emit light from a single point in a direction limited by a set of cones.
- Rect Lights emit light from a rectangular surface in a direction.
Read more (https://dev.epicgames.com/documentation/en-us/unreal-engine/light-types-and-their-mobility-in-unreal-engine) ///
Constructorโ
local myLight = Light(
Vector(0,0,300),
Rotator(45,0,0),
LinearColor(1,0.5,0.5,1),
LightType.Spot,
8000,
1200,
30,
0.2,
5000,
true,
true,
true
)
| Name | Type | Default | Description |
|---|---|---|---|
Location | Vector | (0,0,0) | Spawn position in world space |
Rotation | Rotator | (0,0,0) | Initial rotation of the light |
Color | LinearColor | white | Light color and alpha |
LightTypeParam | enum | LightType.Point | LightType.Point, .Spot, .Rect |
Intensity | number | 5000 | Light brightness (in lumens) |
AttenuationRadius | number | 1000 | Distance the light affects (Point/Spot only) |
ConeAngle | number | 44 | Outer angle for Spot lights |
InnerConePercent | number | 0 | Inner angle as a percent of outer angle |
MaxDrawDistance | number | 0 | Fade out distance (0 = infinite) |
UseInverseSquaredFalloff | boolean | true | Use physically accurate light falloff |
CastShadows | boolean | true | Enable shadow casting |
Visible | boolean | true | Whether the light is visible |
Functionsโ
ToggleEnabledโ
Enables/disables the light
myLight:ToggleEnabled()
IsEnabledโ
Returns boolean of enabled status of light
- returns:
boolean
local isEnabled = myLight:IsEnabled()
GetLightColorโ
Returns the current color of the light
- returns:
Color
local color = myLight:GetLightColor()
GetBrightnessโ
Returns brightness amount
- returns:
integer
local brightness = myLight:GetBrightness()
SetLightFColorโ
Set the color of the light
- NewLightColor:
Color
myLight:SetLightFColor(Color(255, 0, 128, 255))
SetLightColorโ
Set the color of the light
- NewLightColor:
LinearColor
myLight:SetLightColor(LinearColor(1.0, 0.0, 0.5, 1.0))
SetLightFunctionScaleโ
Sets the scale of the light function projection
- NewLightFunctionScale:
Vector
myLight:SetLightFunctionScale(Vector(0,0,0))
SetLightFunctionMaterialโ
Sets a material to use as the light function (gobo effect)
- NewLightFunctionMaterial:
UMaterialInterface
myLight:SetLightFunctionMaterial(myMaterial)
SetLightFunctionFadeDistanceโ
Controls how far the light function effect fades out
- NewLightFunctionFadeDistance:
number
myLight:SetLightFunctionFadeDistance(100)
SetIntensityUnitsโ
Sets how the light's intensity is measured. Options include unitless values, lumens, candelas, or exposure values (EV)
- NewIntensityUnits:
ELightUnits
local units = UE.ELightUnits.Lumens
myLight:SetIntensityUnits(units)
SetAttenuationRadiusโ
Sets the distance at which the light has no effect
- NewRadius:
number
myLight:SetAttenuationRadius(1000)
SetCastShadowsโ
Sets whether this light casts shadows
- bNewValue:
boolean
myLight:SetCastShadows(true)
SetCastVolumetricShadowโ
Enable or disable whether this light casts volumetric shadows
- bNewValue:
boolean
myLight:SetCastVolumetricShadow(true)
SetAffectReflectionโ
Enable or disable this light's influence on reflections
- bNewValue:
boolean
myLight:SetAffectReflection(true)
SetAffectGlobalIlluminationโ
Enable or disable this light's contribution to global illumination
- bNewValue:
boolean
myLight:SetAffectGlobalIllumination(false)
SetVolumetricScatteringIntensityโ
Controls how much this light contributes to the volumetric lighting system
- NewIntensity:
number
myLight:SetVolumetricScatteringIntensity(1.0)
SetUseTemperatureโ
Enable or disable using Kelvin temperature for light color
- bNewValue:
boolean
myLight:SetUseTemperature(true)
SetTemperatureโ
Set the color temperature in Kelvin (only affects light if SetUseTemperature(true) is enabled)
- NewTemperature:
number
myLight:SetTemperature(6500)
SetOuterConeAngleโ
Sets the outer cone angle for spot lights
- NewOuterConeAngle:
number
myLight:SetOuterConeAngle(45)
SetInnerConeAngleโ
Sets the inner cone angle for spot lights
- NewInnerConeAngle:
number
myLight:SetInnerConeAngle(30)
SetSourceWidthโ
Sets the width of the source rectangle for rect lights
- NewValue:
number
myLight:SetSourceWidth(64.0)
SetSourceHeightโ
Sets the height of the source rectangle for rect lights
- NewValue:
number
myLight:SetSourceHeight(128)
SetSourceTextureโ
Assigns a texture to the rect light source
- NewValue:
UTexture
myLight:SetSourceTexture(myTexture)
SetBarnDoorLengthโ
Controls the length of the barn doors for rect lights
- NewValue:
number
myLight:SetBarnDoorLength(10)
SetBarnDoorAngleโ
Controls the angle of the barn doors for rect lights
- NewValue:
number
myLight:SetBarnDoorAngle(45)
SetSourceRadiusโ
Set the radius of the source for point lights
- NewValue:
number
myLight:SetSourceRadius(10)
SetSoftSourceRadiusโ
Set the radius of the soft source effect for point lights
- NewValue:
number
myLight:SetSoftSourceRadius(5)
SetSourceLengthโ
Set the source length for tube-style light emission
- NewValue:
number
myLight:SetSourceLength(20)