エンジンクラス
ParticleEmitter
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
プロパティ
Texture:ContentId |
コードサンプル
ゼロからパーティクルエミッターを作成する
local emitter = Instance.new("ParticleEmitter")
-- パーティクルの数 = 速度 * 寿命
emitter.Rate = 5 -- 秒間のパーティクル数
emitter.Lifetime = NumberRange.new(1, 1) -- パーティクルの寿命(最小、最大)
emitter.Enabled = true
-- ビジュアルプロパティ
emitter.Texture = "rbxassetid://1266170131" -- 白いリングの透明な画像
-- 色のために、ColorSequenceKeypointを使用してColorSequenceを作成します
local colorKeypoints = {
-- API: ColorSequenceKeypoint.new(時間, 色)
ColorSequenceKeypoint.new(0, Color3.new(1, 1, 1)), -- t=0では、白
ColorSequenceKeypoint.new(0.5, Color3.new(1, 0.5, 0)), -- t=0.5では、オレンジ
ColorSequenceKeypoint.new(1, Color3.new(1, 0, 0)), -- t=1では、赤
}
emitter.Color = ColorSequence.new(colorKeypoints)
local numberKeypoints = {
-- API: NumberSequenceKeypoint.new(時間, サイズ, エンベロープ)
NumberSequenceKeypoint.new(0, 1), -- t=0では、完全に透明
NumberSequenceKeypoint.new(0.1, 0), -- t=0.1では、完全に不透明
NumberSequenceKeypoint.new(0.5, 0.25), -- t=0.5では、ほぼ不透明
NumberSequenceKeypoint.new(1, 1), -- t=1では、完全に透明
}
emitter.Transparency = NumberSequence.new(numberKeypoints)
emitter.LightEmission = 1 -- パーティクルが重なると色が明るくなります
emitter.LightInfluence = 0 -- 環境光の影響を受けない
-- 速度プロパティ
emitter.EmissionDirection = Enum.NormalId.Front -- 前方へ放出
emitter.Speed = NumberRange.new(0, 0) -- 速度ゼロ
emitter.Drag = 0 -- パーティクル運動に抗力をかけない
emitter.VelocitySpread = NumberRange.new(0, 0)
emitter.VelocityInheritance = 0 -- 親の速度を引き継がない
emitter.Acceleration = Vector3.new(0, 0, 0)
emitter.LockedToPart = false -- パーティクルを親にロックしない
emitter.SpreadAngle = Vector2.new(0, 0) -- どちらの軸にもスプレッド角度はない
-- シミュレーションプロパティ
local numberKeypoints2 = {
NumberSequenceKeypoint.new(0, 0), -- t=0では、サイズが0
NumberSequenceKeypoint.new(1, 10), -- t=1では、サイズが10
}
emitter.Size = NumberSequence.new(numberKeypoints2)
emitter.ZOffset = -1 -- 実際の位置の少し後ろにレンダリング
emitter.Rotation = NumberRange.new(0, 360) -- ランダム回転で開始
emitter.RotSpeed = NumberRange.new(0) -- シミュレーション中に回転しない
-- パーティクルが正確に同じ場所から放出されるようにアタッチメントを作成します(同心円)
local attachment = Instance.new("Attachment")
attachment.Position = Vector3.new(0, 5, 0) -- アタッチメントを少し上に移動
attachment.Parent = script.Parent
emitter.Parent = attachmentAPIリファレンス
プロパティ
Texture
ParticleEmitter.Texture:ContentId
VelocitySpread
方法
Clear
ParticleEmitter:Clear():()
戻り値
()
コードサンプル
パーティクルエミッターバースト
local emitter = script.Parent
while true do
emitter:Clear()
emitter:Emit(10)
task.wait(2)
endEmit
パラメータ
| 既定値: 16 |
戻り値
()
コードサンプル
距離に沿ってパーティクルを放出
local RunService = game:GetService("RunService")
local emitter = script.Parent
local part = emitter.Parent
local PARTICLES_PER_STUD = 3
local lastPosition = part.Position
local distance = 0
local function onStep()
local displacement = part.Position - lastPosition
distance = distance + displacement.magnitude
local n = math.floor(distance * PARTICLES_PER_STUD)
emitter:Emit(n)
distance = distance - n / PARTICLES_PER_STUD
lastPosition = part.Position
end
RunService.Stepped:Connect(onStep)
emitter.Enabled = falseパーティクルエミッターバースト
local emitter = script.Parent
while true do
emitter:Clear()
emitter:Emit(10)
task.wait(2)
end