Skip to main content

Light

The Light class extends Actor and 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.

tip

Light is an Actor, so it inherits all functions from Actor.

Light Profiles

  • 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.

Constructor

// Lights are spawned via Lua scripting.

Constructor Parameters

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, or .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.

Methods

General

MethodParametersReturn TypeDescription
ToggleEnabled--voidEnables or disables the light.
IsEnabled--booleanReturns the enabled status of the light.
GetLightColor--ColorReturns the current color of the light.
GetBrightness--numberReturns the brightness amount.

Color and Intensity

MethodParametersReturn TypeDescription
SetLightFColorNewLightColor: ColorvoidSets the light color using a Color value.
SetLightColorNewLightColor: LinearColorvoidSets the light color using a LinearColor value.
SetIntensityUnitsNewIntensityUnits: ELightUnitsvoidSets how the light's intensity is measured (unitless, lumens, candelas, or EV).
SetAttenuationRadiusNewRadius: numbervoidSets the distance at which the light has no effect.
SetCastShadowsbNewValue: booleanvoidSets whether the light casts shadows.
SetCastVolumetricShadowbNewValue: booleanvoidEnables or disables volumetric shadow casting.
SetAffectReflectionbNewValue: booleanvoidEnables or disables the light's influence on reflections.
SetAffectGlobalIlluminationbNewValue: booleanvoidEnables or disables the light's contribution to global illumination.
SetVolumetricScatteringIntensityNewIntensity: numbervoidControls the light's contribution to volumetric lighting.
SetUseTemperaturebNewValue: booleanvoidEnables or disables using Kelvin temperature for light color.
SetTemperatureNewTemperature: numbervoidSets the color temperature in Kelvin (requires SetUseTemperature(true)).

Light Function

MethodParametersReturn TypeDescription
SetLightFunctionScaleNewLightFunctionScale: VectorvoidSets the scale of the light function projection.
SetLightFunctionMaterialNewLightFunctionMaterial: UMaterialInterfacevoidSets a material to use as the light function (gobo effect).
SetLightFunctionFadeDistanceNewLightFunctionFadeDistance: numbervoidControls how far the light function effect fades out.

Spot Light

MethodParametersReturn TypeDescription
SetOuterConeAngleNewOuterConeAngle: numbervoidSets the outer cone angle for spot lights.
SetInnerConeAngleNewInnerConeAngle: numbervoidSets the inner cone angle for spot lights.

Rect Light

MethodParametersReturn TypeDescription
SetSourceWidthNewValue: numbervoidSets the width of the source rectangle.
SetSourceHeightNewValue: numbervoidSets the height of the source rectangle.
SetSourceTextureNewValue: UTexturevoidAssigns a texture to the rect light source.
SetBarnDoorLengthNewValue: numbervoidControls the length of the barn doors.
SetBarnDoorAngleNewValue: numbervoidControls the angle of the barn doors.

Point Light

MethodParametersReturn TypeDescription
SetSourceRadiusNewValue: numbervoidSets the radius of the source for point lights.
SetSoftSourceRadiusNewValue: numbervoidSets the radius of the soft source effect.
SetSourceLengthNewValue: numbervoidSets the source length for tube-style light emission.

Examples

Dynamic Spotlight

// Lights are spawned and configured via Lua scripting.

Performance

Dynamic shadow-casting lights are expensive. Use SetCastShadows(false) for ambient or decorative lights that do not need shadows.