类型
类型 | 详情 |
---|---|
PointLight | 从一个点向所有方向发射光线。 |
SpotLight | 以锥形发射光线,适用于创建聚焦光束。 |
SurfaceLight | 从一个表面向一个方向发射光线,适用于区域照明。 |
属性
属性 | 详情 |
---|---|
Brightness | 控制光的强度。 |
Color | 设置光的颜色。 |
Range | 确定光线的照射范围。 |
Shadows | 启用或禁用光线投射的阴影。 |
Angle | 定义光束的扩散范围。 (SpotLight 和 SurfaceLight) |
Face | 指定光线发射的方向。 (SpotLight 和 SurfaceLight) |
Enabled | 切换光源的开启或关闭。 |
光效示例
使用 PointLight
local part = script.Parent
local pointLight = Instance.new("PointLight")
pointLight.Parent = part
pointLight.Brightness = 2 -- Controls the intensity of the light
pointLight.Color = Color3.fromRGB(255, 255, 255) -- White light
pointLight.Range = 16 -- How far the light reaches
pointLight.Shadows = true -- Enable shadows
pointLight.Enabled = true -- Ensure the light is turned on
-- Function to toggle the light on and off every 1 second
while true do
pointLight.Enabled = not pointLight.Enabled -- Toggle the light's enabled state
wait(1) -- Wait for 1 second before toggling again
end
Roblox Studio
使用 SpotLight
local part = script.Parent
local spotLight = Instance.new("SpotLight")
spotLight.Parent = part
spotLight.Brightness = 8 -- Controls the intensity of the light
spotLight.Color = Color3.fromRGB(255, 255, 255) -- White light
spotLight.Range = 16 -- How far the light reaches
spotLight.Shadows = true -- Enable shadows
spotLight.Angle = 90 -- Width of the cone (in degrees)
spotLight.Face = Enum.NormalId.Front -- Direction the light is facing
spotLight.Enabled = true -- Ensure the light is turned on
-- Function to toggle the light on and off every 1 second
while true do
spotLight.Enabled = not spotLight.Enabled -- Toggle the light's enabled state
wait(1) -- Wait for 1 second before toggling again
end
Roblox Studio
使用 SurfaceLight
local part = script.Parent
local pointLight = Instance.new("PointLight")
pointLight.Parent = part
pointLight.Brightness = 2 -- Controls the intensity of the light
pointLight.Color = Color3.fromRGB(255, 255, 255) -- White light
pointLight.Range = 16 -- How far the light reaches
pointLight.Shadows = true -- Enable shadows
pointLight.Enabled = true -- Ensure the light is turned on
-- Function to toggle the light on and off every 1 second
while true do
pointLight.Enabled = not pointLight.Enabled -- Toggle the light's enabled state
wait(1) -- Wait for 1 second before toggling again
end
Roblox Studio