Skip to main content
Version: latest - a1.172.0 โš–๏ธ

๐Ÿ’ก Light

A Light represents a Lighting source

Client & Server๐Ÿ”Not Distributable๐Ÿง‘โ€๐Ÿ’ปAPI Source
๐Ÿ‘ชInheritance
This class shares methods and events from Base Entity, Base Actor.

๐ŸŽ’ Examplesโ€‹

Server/Index.lua
local my_light = Light(
Vector(-152, 245, 115),
Rotator(0, 90, 90), -- Relevant only for Rect and Spot light types
Color(1, 0, 0), -- Red Tint
LightType.Point, -- Point Light type
100, -- Intensity
250, -- Attenuation Radius
44, -- Cone Angle (Relevant only for Spot light type)
0, -- Inner Cone Angle Percent (Relevant only for Spot light type)
5000, -- Max Draw Distance (Good for performance - 0 for infinite)
true, -- Whether to use physically based inverse squared distance falloff, where Attenuation Radius is only clamping the light's contribution. (Spot and Point types only)
true, -- Cast Shadows?
true -- Enabled?
)

๐Ÿ›  Constructorsโ€‹

Default Constructorโ€‹

No description provided

local my_light = Light(location, rotation?, color?, light_type?, intensity?, attenuation_radius?, cone_angle?, inner_cone_angle_percent?, max_draw_distance?, use_inverse_squared_falloff?, cast_shadows?, visible?, source_radius?, spawn_mode?)
Parameters
NameTypeDescription
locationVectorWorld location to spawn at
rotation?RotatorRelevant only for Rect and Spot LightTypes Default Rotator(0, 0, 0)
color?ColorColor of the light Default Color(1, 1, 1)
light_type?LightTypePoint, Spot or Rect Default LightType.Point
intensity?floatBrightness of the light Default 30
attenuation_radius?floatDistance the light reaches Default 250
cone_angle?floatRelevant only for Spot LightType Default 44
inner_cone_angle_percent?floatInner Cone Angle Percent (Relevant only for Spot LightType) (0-1) Default 0
max_draw_distance?floatMax Draw Distance (Good for performance) - 0 for infinite Default 10000
use_inverse_squared_falloff?booleanWhether to use physically based inverse squared distance falloff, where Attenuation Radius is only clamping the light's contribution. (Spot and Point types only) Default true
cast_shadows?booleanWhether the light casts shadows Default true
visible?booleanWhether the light starts visible Default true
source_radius?floatRadius of light source shape. (Spot and Point types only) Default 2
spawn_mode?SpawnModePass SpawnMode.AfterConstructor or SpawnMode.Manual to avoid immediately sending the entity to clients and improve performance when you want to configure it by setting several configs. Must call FinishSpawn() after all Default SpawnMode.Immediate
tip

nanos world provides 3 types of lights: Spot, Point and Rect. All lights are Dynamic and because of that, very expensive! Keep that in mind before spawning 1000 lights ๐Ÿ˜‰.

๐Ÿ—ฟ Static Functionsโ€‹

This class doesn't have own static functions.

Inherited static functions

๐Ÿฆ  Functionsโ€‹

GetAttenuationRadius: floatGets the distance this Light reaches
GetCastShadows: booleanGets if this Light casts shadows
GetColor: ColorGets the color of this Light
GetIntensity: floatGets the brightness of this Light
SetAttenuationRadiusSets the distance this Light reaches
SetCastShadowsSets if this Light casts shadows
SetColorSets the light color
SetIntensitySets the brightness of this Light
SetTextureLightProfileSets the light Texture Profile

GetAttenuationRadiusOptimalโ€‹

Gets the distance this Light reaches

local attenuation_radius = my_light:GetAttenuationRadius()
Returns
TypeDescription
floatThe attenuation radius

See also SetAttenuationRadius.

GetCastShadowsOptimalโ€‹

Gets if this Light casts shadows

local is_shadows_enabled = my_light:GetCastShadows()
Returns
TypeDescription
booleanWhether it casts shadows

See also SetCastShadows.

GetColorOptimalโ€‹

Gets the color of this Light

local color = my_light:GetColor()
Returns
TypeDescription
ColorThe light color

See also SetColor.

GetIntensityOptimalโ€‹

Gets the brightness of this Light

local intensity = my_light:GetIntensity()
Returns
TypeDescription
floatThe brightness

See also SetIntensity.

SetAttenuationRadiusOptimalโ€‹

Sets the distance this Light reaches

my_light:SetAttenuationRadius(attenuation_radius)
Parameters
NameTypeDescription
attenuation_radiusfloatThe new attenuation radius

See also GetAttenuationRadius.

SetCastShadowsOptimalโ€‹

Sets if this Light casts shadows

my_light:SetCastShadows(is_shadows_enabled)
Parameters
NameTypeDescription
is_shadows_enabledbooleanWhether it casts shadows

See also GetCastShadows.

SetColorOptimalโ€‹

Sets the light color

my_light:SetColor(color)
Parameters
NameTypeDescription
colorColorThe light color

See also GetColor.

SetIntensityOptimalโ€‹

Sets the brightness of this Light

my_light:SetIntensity(intensity)
Parameters
NameTypeDescription
intensityfloatThe new brightness

See also GetIntensity.

SetTextureLightProfileOptimalโ€‹

Sets the light Texture Profile

my_light:SetTextureLightProfile(light_profile)
Parameters
NameTypeDescription
light_profileLightProfileThe Light Profile to use

See also ๐Ÿ’ก Light Profiles.

๐Ÿš€ Eventsโ€‹

This class doesn't have own events.

๐Ÿ’ก Light Profilesโ€‹

Light Profiles are texture files which describes a light's distribution from a light source using real world measured data.

tip

Please check Unreal Engine Light Profile documentation for more information about Light Profiles!

nanos world provides 50 Light Profiles included in the base game which you can use to enhance your Lights. You can set them using :SetTextureLightProfile() with the enum LightProfile.