煙は複数の粒子放出クラスの 1つです。同じ種類の他の粒子エミッターと同様、スモークオブジェクトは、親に (例: ) またはそのような 内の粒子を放射します。ParticleEmitter クラスと比較して、スモークには ParticleEmitter.Lifetime または ParticleEmitter:Emit() などの多くの異なるカスタマイズプロパティと特別なメソッドが欠落しています。ピンチで素早い特殊効果を作成するのは便利です;詳細な作業のためには、代わりに ParticleEmitter を使用することを推奨します。
Smoke.Enabled が切り替えられると、このオブジェクトによって放オフされる粒子は、期限が切れるまでレンダリングを続けます。スモークオブジェクトの が に設定されると、すべてのパーティクルがすぐに消えます。この効果が望ましくない場合は、親オブジェクトを遠くの位置に隠し、Debris を使用して数秒後に煙を削除して、最後の粒子が期限切れするチャンスを与えます。このオブジェクトには ParticleEmitter:Clear() メソッドはありませんが、Instance.Parent を nil に設定し、同じ効果で同じオブジェクトに戻すことができます。
スモークパーティクルは、親属している BasePart の中心からのみ放出されます。スモークオブジェクトを Attachment に親にすることで、パーティクルの開始位置のカスタマイズが可能になります。
コードサンプル
This code sample adds a Smoke object to every Fire object in the Workspace. It does this by using a recursive search.
local function recurseForFire(object)
-- Check if we found a Fire object that has no Smoke
if object:IsA("Fire") and not object.Parent:FindFirstChildOfClass("Smoke") then
-- Create a smoke effect for this fire
local smoke = Instance.new("Smoke")
smoke.Color = Color3.new(0, 0, 0)
smoke.Opacity = 0.15
smoke.RiseVelocity = 4
smoke.Size = object.Size / 4
smoke.Parent = object.Parent
end
-- Continue search for Fire objects
for _, child in pairs(object:GetChildren()) do
recurseForFire(child)
end
end
recurseForFire(workspace)
概要
プロパティ
煙パーティクルの色を決定します。
煙粒子が放出されるかどうかを決定します。
不透明な煙粒子のレンダリング方法を決定します。
煙粒子の速度を決定します。
新しく放出される煙パーティクルのサイズを決定します。
パーティクル効果の速度を制御する 0-1 の値。
プロパティ
Color
カラープロパティは、Smoke オブジェクト (既存のパーティクルと将来のパーティクルの両方) によって放出されるすべてのパーティクルの色を決定します。それは、ParticleEmitter.Color と同様に動作しますが、1色であり、ColorSequence ではありません。白の色と少しの Smoke.Opacity が美しい霧効果を生み出し、非常に不透明な黒の色は Fire オブジェクトを美しく補完できます。
コードサンプル
This code sample adds a Smoke object to every Fire object in the Workspace. It does this by using a recursive search.
local function recurseForFire(object)
-- Check if we found a Fire object that has no Smoke
if object:IsA("Fire") and not object.Parent:FindFirstChildOfClass("Smoke") then
-- Create a smoke effect for this fire
local smoke = Instance.new("Smoke")
smoke.Color = Color3.new(0, 0, 0)
smoke.Opacity = 0.15
smoke.RiseVelocity = 4
smoke.Size = object.Size / 4
smoke.Parent = object.Parent
end
-- Continue search for Fire objects
for _, child in pairs(object:GetChildren()) do
recurseForFire(child)
end
end
recurseForFire(workspace)
Enabled
有効属性は、ParticleEmitter.Enabled と同様に、煙粒子が放出されるかどうかを決定します。既に放出されているすべての粒子は、期限が切れるまでレンダリングを続けます。このプロパティは、後で必要になるまでプリメイドのスモーク効果を保持するのに便利です。煙の粒子は、Smoke オブジェクトの Instance.Parent が nil に設定されると破壊されるため、このプロパティは、煙オブジェクト全体を破壊する前に、既存の粒子が期限切れになる機会を与えることができます。以下の機能を参照してください。
local Debris = game:GetService("Debris")
local part = script.Parent
function stopSmoke(smoke)
smoke.Enabled = false -- No more new particles
Debris:AddItem(smoke, 10) -- Remove the object after a delay (after existing particles have expired)
end
stopSmoke(part.Smoke)
コードサンプル
This code sample adds a Smoke object to every Fire object in the Workspace. It does this by using a recursive search.
local function recurseForFire(object)
-- Check if we found a Fire object that has no Smoke
if object:IsA("Fire") and not object.Parent:FindFirstChildOfClass("Smoke") then
-- Create a smoke effect for this fire
local smoke = Instance.new("Smoke")
smoke.Color = Color3.new(0, 0, 0)
smoke.Opacity = 0.15
smoke.RiseVelocity = 4
smoke.Size = object.Size / 4
smoke.Parent = object.Parent
end
-- Continue search for Fire objects
for _, child in pairs(object:GetChildren()) do
recurseForFire(child)
end
end
recurseForFire(workspace)
LocalTransparencyModifier
Opacity
不透明度は、煙粒子の不透明度を決定します。範囲 [0, 1] 内にある必要があります。このプロパティは、パーツの **** またはパーティクルエミッターの BasePart.Transparency と比較して、ParticleEmitter.Transparency 逆向きで動作します:値 0 は完全に見えません、1 は全く見えます。
Roblox が Smoke 粒子に使用するテクスチャは部分的に透明であるため、このプロパティを 1 に設定すると、レンダリングされた煙に透明性が残ります。
コードサンプル
This code sample adds a Smoke object to every Fire object in the Workspace. It does this by using a recursive search.
local function recurseForFire(object)
-- Check if we found a Fire object that has no Smoke
if object:IsA("Fire") and not object.Parent:FindFirstChildOfClass("Smoke") then
-- Create a smoke effect for this fire
local smoke = Instance.new("Smoke")
smoke.Color = Color3.new(0, 0, 0)
smoke.Opacity = 0.15
smoke.RiseVelocity = 4
smoke.Size = object.Size / 4
smoke.Parent = object.Parent
end
-- Continue search for Fire objects
for _, child in pairs(object:GetChildren()) do
recurseForFire(child)
end
end
recurseForFire(workspace)
RiseVelocity
RiseVelocity は ParticleEmitter.Speed および Fire.Heat と同様に動作します:喫煙粒子が生涯中にどれほど速く移動するかを決定します。範囲は [-25, 25] でなければなりません。ネガティブな値は、粒子が親の BasePart の下向き (-Y) 方向に放出されるようにします。
霧を作成するときに Smoke 効果を使用すると、このプロパティを 0 に設定します。大きな煙の効果の場合、上昇を微妙にします (2 から 8)。煙突と煙突には、より高い値が適しています。
コードサンプル
This code sample adds a Smoke object to every Fire object in the Workspace. It does this by using a recursive search.
local function recurseForFire(object)
-- Check if we found a Fire object that has no Smoke
if object:IsA("Fire") and not object.Parent:FindFirstChildOfClass("Smoke") then
-- Create a smoke effect for this fire
local smoke = Instance.new("Smoke")
smoke.Color = Color3.new(0, 0, 0)
smoke.Opacity = 0.15
smoke.RiseVelocity = 4
smoke.Size = object.Size / 4
smoke.Parent = object.Parent
end
-- Continue search for Fire objects
for _, child in pairs(object:GetChildren()) do
recurseForFire(child)
end
end
recurseForFire(workspace)
Size
Smoke のサイズプロパティは、新しく放出される煙粒子のサイズを決定します。Smoke.Color とは異なり、このプロパティは既存のパーティクルのサイズを変更しません。範囲 [0.1、100] 内にある必要があります。ParticleEmitter.Size とは異なり、このプロパティは数字のみです(NumberSequence ではありません)。また、パーティクルのサイズがスタッドと 1対1 ではないことにも注意してください; 実際、煙パーティクルのサイズは 2 倍以上大きいです。最大サイズでは、煙粒子は 200スタッド以上の幅でレンダリングできます!
コードサンプル
This code sample adds a Smoke object to every Fire object in the Workspace. It does this by using a recursive search.
local function recurseForFire(object)
-- Check if we found a Fire object that has no Smoke
if object:IsA("Fire") and not object.Parent:FindFirstChildOfClass("Smoke") then
-- Create a smoke effect for this fire
local smoke = Instance.new("Smoke")
smoke.Color = Color3.new(0, 0, 0)
smoke.Opacity = 0.15
smoke.RiseVelocity = 4
smoke.Size = object.Size / 4
smoke.Parent = object.Parent
end
-- Continue search for Fire objects
for _, child in pairs(object:GetChildren()) do
recurseForFire(child)
end
end
recurseForFire(workspace)