点光源是一个发射单点照明的光源。光照是根据点光源的 PointLight.Range 发射的球面。
为了使点光源提供照明,它必须是 BasePart 或 Attachment (部分或附件本身必须是 Workspace 的后裔) 的直接子女。
如果点光源被父辈到零件上,那么光将从零件的 BasePart.Position 发出。如果点光源被附加到附件上,那么光将从附件的 Attachment.WorldPosition 发出。
对于更多的灯光类型,请参阅 也看 部分。
还看到也看到
代码示例
This example creates a new anchored BasePart named Part at the position {0, 0, 0}.
It then creates a new point light with brightness of 1, Color3 color of {255/255, 255/255, 255/255} (white) and range of 16 studs. The point light's parent is set to the BasePart we created. To view the light, navigate to the part at {0, 0, 0} or move the Part created to a location visible to the player.
Please note that the properties of the created point light can easily be changed by modifying the property values in the code sample below. Additionally, if you have an existing point light, you can also create a similar script that modifies that light instead of creating a new BasePart and light.
local part = Instance.new("Part")
part.Anchored = true
part.Position = Vector3.new(0, 0, 0)
part.Parent = workspace
local light = Instance.new("PointLight")
light.Color = Color3.new(1, 1, 1)
light.Brightness = 1
light.Range = 16
light.Parent = part