Skip to main content

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โ€‹

Example
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
)
NameTypeDefaultDescription
LocationVector(0,0,0)Spawn position in world space
RotationRotator(0,0,0)Initial rotation of the light
ColorLinearColorwhiteLight color and alpha
LightTypeParamenumLightType.PointLightType.Point, .Spot, .Rect
Intensitynumber5000Light brightness (in lumens)
AttenuationRadiusnumber1000Distance the light affects (Point/Spot only)
ConeAnglenumber44Outer angle for Spot lights
InnerConePercentnumber0Inner angle as a percent of outer angle
MaxDrawDistancenumber0Fade out distance (0 = infinite)
UseInverseSquaredFalloffbooleantrueUse physically accurate light falloff
CastShadowsbooleantrueEnable shadow casting
VisiblebooleantrueWhether the light is visible

Functionsโ€‹

ToggleEnabledโ€‹

Enables/disables the light

Example
myLight:ToggleEnabled()

IsEnabledโ€‹

Returns boolean of enabled status of light

  • returns: boolean
Example
local isEnabled = myLight:IsEnabled()

GetLightColorโ€‹

Returns the current color of the light

  • returns: Color
Example
local color = myLight:GetLightColor()

GetBrightnessโ€‹

Returns brightness amount

  • returns: integer
Example
local brightness = myLight:GetBrightness()

SetLightFColorโ€‹

Set the color of the light

  • NewLightColor: Color
Example
myLight:SetLightFColor(Color(255, 0, 128, 255))

SetLightColorโ€‹

Set the color of the light

  • NewLightColor: LinearColor
Example
myLight:SetLightColor(LinearColor(1.0, 0.0, 0.5, 1.0))

SetLightFunctionScaleโ€‹

Sets the scale of the light function projection

  • NewLightFunctionScale: Vector
Example
myLight:SetLightFunctionScale(Vector(0,0,0))

SetLightFunctionMaterialโ€‹

Sets a material to use as the light function (gobo effect)

  • NewLightFunctionMaterial: UMaterialInterface
Example
myLight:SetLightFunctionMaterial(myMaterial)

SetLightFunctionFadeDistanceโ€‹

Controls how far the light function effect fades out

  • NewLightFunctionFadeDistance: number
Example
myLight:SetLightFunctionFadeDistance(100)

SetIntensityUnitsโ€‹

Sets how the light's intensity is measured. Options include unitless values, lumens, candelas, or exposure values (EV)

  • NewIntensityUnits: ELightUnits
Example
local units = UE.ELightUnits.Lumens
myLight:SetIntensityUnits(units)

SetAttenuationRadiusโ€‹

Sets the distance at which the light has no effect

  • NewRadius: number
Example
myLight:SetAttenuationRadius(1000)

SetCastShadowsโ€‹

Sets whether this light casts shadows

  • bNewValue: boolean
Example
myLight:SetCastShadows(true)

SetCastVolumetricShadowโ€‹

Enable or disable whether this light casts volumetric shadows

  • bNewValue: boolean
Example
myLight:SetCastVolumetricShadow(true)

SetAffectReflectionโ€‹

Enable or disable this light's influence on reflections

  • bNewValue: boolean
Example
myLight:SetAffectReflection(true)

SetAffectGlobalIlluminationโ€‹

Enable or disable this light's contribution to global illumination

  • bNewValue: boolean
Example
myLight:SetAffectGlobalIllumination(false)

SetVolumetricScatteringIntensityโ€‹

Controls how much this light contributes to the volumetric lighting system

  • NewIntensity: number
Example
myLight:SetVolumetricScatteringIntensity(1.0)

SetUseTemperatureโ€‹

Enable or disable using Kelvin temperature for light color

  • bNewValue: boolean
Example
myLight:SetUseTemperature(true)

SetTemperatureโ€‹

Set the color temperature in Kelvin (only affects light if SetUseTemperature(true) is enabled)

  • NewTemperature: number
Example
myLight:SetTemperature(6500)

SetOuterConeAngleโ€‹

Sets the outer cone angle for spot lights

  • NewOuterConeAngle: number
Example
myLight:SetOuterConeAngle(45)

SetInnerConeAngleโ€‹

Sets the inner cone angle for spot lights

  • NewInnerConeAngle: number
Example
myLight:SetInnerConeAngle(30)

SetSourceWidthโ€‹

Sets the width of the source rectangle for rect lights

  • NewValue: number
Example
myLight:SetSourceWidth(64.0)

SetSourceHeightโ€‹

Sets the height of the source rectangle for rect lights

  • NewValue: number
Example
myLight:SetSourceHeight(128)

SetSourceTextureโ€‹

Assigns a texture to the rect light source

  • NewValue: UTexture
Example
myLight:SetSourceTexture(myTexture)

SetBarnDoorLengthโ€‹

Controls the length of the barn doors for rect lights

  • NewValue: number
Example
myLight:SetBarnDoorLength(10)

SetBarnDoorAngleโ€‹

Controls the angle of the barn doors for rect lights

  • NewValue: number
Example
myLight:SetBarnDoorAngle(45)

SetSourceRadiusโ€‹

Set the radius of the source for point lights

  • NewValue: number
Example
myLight:SetSourceRadius(10)

SetSoftSourceRadiusโ€‹

Set the radius of the soft source effect for point lights

  • NewValue: number
Example
myLight:SetSoftSourceRadius(5)

SetSourceLengthโ€‹

Set the source length for tube-style light emission

  • NewValue: number
Example
myLight:SetSourceLength(20)
โœจ