Fire

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

火焰 是几个预制粒子发射类别之一。像其他颗粒发射对象一样,火焰在接受到父辈时发射颗粒,而在 和 时则不发射颗粒。该对象有助于在紧急情况下创建快速的视觉效果;对于更详细的工作,建议使用 ParticleEmitter 来进行。

火焰粒子从BasePart中心发射到它们的父辈。粒子向上发射(+Y)方向;然而,负Fire.Heat可以用于向下发射(-Y)方向。使用 Attachment 作为父而不使用 Attachment.CFrame 或相关属性来修改排放位置/方向。

Enabled关闭时,现有粒子继续渲染直到它们过期。然而,如果火焰的 Parent 设置为 nil 所有现有粒子立即消失,与 ParticleEmitter:Clear() 的行为类似。设置 Parentnil 并返回到准确的原始对象来实现相同的效果是可行的。如果不希望立即消失,请尝试将火焰的父辈移至一些遥远的位置,然后 几秒钟后移动火焰。这将给现有的粒子时间到期。

火焰对象不会自拥有发出光。要帮助创建燃烧物周围的协调环境,请尝试添加一个橙色的 PointLight 与一个橙色的 Color 。这可以帮助你的火焰看起来更加真实。

火焰对象由两个发射器组成。这两者都受到火焰的 Size , Heat , ColorSecondaryColor 的各种影响。较小的次要发射器发出的粒子的寿命(和升高高度)比主要发射器发出的粒子要长得多(且升高得更远)。在右侧的视频中,你可以看到两个具有不同颜色的发射器。

与实际火焰不同,火焰对象 不会自行扩散 。如果你在游戏中发现这种行为,那是因为有一个 Script 导致的。

代码示例

This code sample adds Fire to all BasePart in the Workspace named "Torch".

Lighting Torches

for _, child in pairs(workspace:GetChildren()) do
if child.Name == "Torch" and child:IsA("BasePart") then
local fire = Instance.new("Fire")
fire.Heat = 10
fire.Color = child.Color
fire.SecondaryColor = Color3.new(1, 1, 1) -- White
fire.Size = math.max(child.Size.X, child.Size.Z) -- Pick the larger of the two dimensions
fire.Parent = child
end
end

概要

属性

属性

Color

读取并联

颜色属性决定了由 Fire 对象发射的更大粒子的颜色。它基本上是火焰外部的颜色。

一通用来说,冷焰在触发的外面。因此,如果外部部分是红色或橙黄色,火焰看起来更像现实。整个明亮的火焰看起来不太现实,所以避免将此属性设置为黄色。尝试将 PointLightPointLight.Color 作为兄弟添加到 Fire 。这将为周围环境提供光,使其与火焰粒子更加协调。

代码示例

This code sample adds Fire to all BasePart in the Workspace named "Torch".

Lighting Torches

for _, child in pairs(workspace:GetChildren()) do
if child.Name == "Torch" and child:IsA("BasePart") then
local fire = Instance.new("Fire")
fire.Heat = 10
fire.Color = child.Color
fire.SecondaryColor = Color3.new(1, 1, 1) -- White
fire.Size = math.max(child.Size.X, child.Size.Z) -- Pick the larger of the two dimensions
fire.Parent = child
end
end

Enabled

读取并联

启用属性,与 ParticleEmitter.Enabled 类似,决定是否发射火焰粒子。任何已发射的粒子将继续渲染,直到其使用期过期。此属性有助于保持预制的火焰效果直到稍后需要它们为止。由于火焰粒子在 Fire 对象的 Instance.Parent 设置为 nil 时被摧毁,这个属性有助于允许现有粒子在摧毁火焰对象之前有机会过期。请参阅下面的函数。


local Debris = game:GetService("Debris")
local part = script.Parent
function douseFlames(fire)
fire.Enabled = false -- No more new particles
Debris:AddItem(fire, 2) -- Remove the object after a delay (after existing particles have expired)
end
douseFlames(part.Fire)

代码示例

This code sample allows a player to click the parent BasePart to toggle a fire effect.

Toggle Fire Effect

local part = script.Parent
local clickDetector = Instance.new("ClickDetector")
clickDetector.Parent = part
local fire = Instance.new("Fire")
fire.Parent = part
local light = Instance.new("PointLight")
light.Parent = part
local function onClick()
fire.Enabled = not fire.Enabled
light.Enabled = fire.Enabled
end
clickDetector.MouseClick:Connect(onClick)

Heat

未复制
读取并联

热量属性决定了粒子从 Fire 对象发射的速度。它仅限于范围 [-25, 25]。正值位于父辈 BasePartAttachment 的顶部(+Y)方向。它还会影响内部粒子的 ParticleEmitter.Acceleration 。下面,你可以看到更高的热对火焰粒子的速度/加速的影响(左有热量=9,右有热量=18)。

代码示例

This code sample adds Fire to all BasePart in the Workspace named "Torch".

Lighting Torches

for _, child in pairs(workspace:GetChildren()) do
if child.Name == "Torch" and child:IsA("BasePart") then
local fire = Instance.new("Fire")
fire.Heat = 10
fire.Color = child.Color
fire.SecondaryColor = Color3.new(1, 1, 1) -- White
fire.Size = math.max(child.Size.X, child.Size.Z) -- Pick the larger of the two dimensions
fire.Parent = child
end
end

LocalTransparencyModifier

隐藏
未复制
读取并联

SecondaryColor

读取并联

次要颜色属性决定由 Fire 对象发射的更小粒子的颜色。它基本上是火焰内部部分的颜色。以下,你可以看到火焰的次要颜色设置为白色与更大、外部粒子区分,其中 Fire.Color 设置为蓝色。需要注意的是,内部粒子使用 ParticleEmitter.LightEmission 的 1,因此黑暗颜色会导致粒子变得透明(因此黑色将完全停止渲染内部粒子)。

代码示例

This code sample adds Fire to all BasePart in the Workspace named "Torch".

Lighting Torches

for _, child in pairs(workspace:GetChildren()) do
if child.Name == "Torch" and child:IsA("BasePart") then
local fire = Instance.new("Fire")
fire.Heat = 10
fire.Color = child.Color
fire.SecondaryColor = Color3.new(1, 1, 1) -- White
fire.Size = math.max(child.Size.X, child.Size.Z) -- Pick the larger of the two dimensions
fire.Parent = child
end
end

Size

未复制
读取并联

该属性决定了火焰粒子的尺寸。它必须在 2 到 30 之间。与 ParticleEmitter.Size 不同,火焰的实际尺寸不会与等值尺寸的螺柱匹配 1:1;它略小一些。

为了使您的环境更加协调,尝试将 PointLight 添加到 Fire 对象作为兄弟。将 PointLight.BrightnessPointLight.Range 设置为这个属性,以便更大的火焰产生更多的光。

代码示例

This code sample adds Fire to all BasePart in the Workspace named "Torch".

Lighting Torches

for _, child in pairs(workspace:GetChildren()) do
if child.Name == "Torch" and child:IsA("BasePart") then
local fire = Instance.new("Fire")
fire.Heat = 10
fire.Color = child.Color
fire.SecondaryColor = Color3.new(1, 1, 1) -- White
fire.Size = math.max(child.Size.X, child.Size.Z) -- Pick the larger of the two dimensions
fire.Parent = child
end
end

TimeScale

读取并联

小于 0-1 的值控制粒子效果的速度。在 1 处,它以正常速度运行,在 0.5 处,它以半速运行,在 0 处,它冻结时间。

方法

活动