Home / Lua / Client / ClientLight / Static Functions / Create


Returns    ClientLight
Prototype    ClientLight.Create(table arguments)
Description    No description

Argument table

Required values

Type Name Notes
Vector3 position
Color color

Optional values

Type Name Default Notes
number multiplier 1 The brightness. Values above 16 don't affect much.
number radius 2
number constant_attenuation 1 See here
number linear_attenuation 0.1 See here
number quadratic_attenuation 0.01 See here
number fade_in_duration 0.2
number fade_out_duration 0.2

Examples

Spawn a light where you click

lights = {}

Events:Subscribe("MouseDown", function(args)
	if args.button ~= 1 then
		return
	end
	
	local result = Physics:Raycast(
		Camera:GetPosition(),
		Camera:GetAngle() * Vector3.Forward,
		0,
		100
	)
	
	local light = ClientLight.Create{
		position = result.position + result.normal * 1.5,
		color = Color.FromHSV(math.random(1, 360), 1, 1),
		constant_attenuation = 0,
		linear_attenuation = 0,
		quadratic_attenuation = 1,
		multiplier = 3.0,
		radius = 15.0,
	}
	
	table.insert(lights, light)
end)

-- Make sure to clean up all of our lights on ModuleUnload.
Events:Subscribe("ModuleUnload", function()
	for index, light in ipairs(lights) do
		light:Remove()
	end
end)