Explosion

非推奨を表示

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。

爆発は、爆発内の BaseParts に力を適用します。BlastRadius 。この力は、パーツの間の JointInstancesWeldConstraints を破壊し、Humanoid に保護されていないキャラクターを殺します。これは、ForceField によって保護されていないパーツの間で起こります。Constraints は爆発によって壊れません。

エクスペリエンスが実行されている間、データモデルのどこかで Explosion が親になっている場合、すぐに起動し、数秒以内に親から切り離されます。この場合、Instance:Destroy() で破壊されないので、接続が切断されず、親がロックされない。すべてのインスタンスと同様、強い参照を Explosion 保持すると、ゴミ回収されるのを防げます。

爆発ビジュアルが再生され、物理/破壊効果が影響を与えるためには、ExplosionWorkspaceの子孫である必要があることに注意してください。

爆発効果

Humanoids は爆発で殺され、爆発がキャラクターの Model 首関節を破壊するときに殺されます。親がモデルに ForceField をパーティングすると、すべての子供が爆発キル効果から保護されます。

BaseParts からHumanoidsへの接合が壊れないようにしたい、またはDestroyJointRadiusPercentへのダメージフォーミュラを実装したい場合、爆発の結果を処理するためにHitイベントを使用することをお勧めします。

爆発は、Terrain にダメージを与えるように構成することもでき、ExplosionType プロパティを通じて設定されるように、クレーターを作成します。

爆発の効果は、 障害物によって中断されない 、つまり、他のパーツ/地形の後ろにシールドされたパーツ/地形がまだ影響を受けることに注意してください。

コードサンプル

This code sample includes a brief snippet that creates a large explosion in the game at 0, 10, 0.

Explosion Instantiation

local explosion = Instance.new("Explosion")
explosion.BlastRadius = 60
explosion.ExplosionType = Enum.ExplosionType.Craters -- damages terrain
explosion.Position = Vector3.new(0, 10, 0)
explosion.Parent = workspace

概要

プロパティ

  • 並列読み取り

    BaseParts に捕まえられた力の量を決定するために使用されます。Explosion.BlastRadius に捕まえられた力の量を決定するために使用されます。

  • 並列読み取り

    このプロパティは、スタッドで Explosion の半径を決定します。この半径は爆発の視覚サイズではなく、爆発の効果エリアを決定します。

  • 0から1の間の Explosion.BlastRadius の割合を設定し、すべてのジョイントが破壊される領域を設定するために使用されます。この範囲外のものは、Explosion フォースが適用されるだけです。

  • このプロパティは、ExplosionTerrain とどのように相互作用するかを決定します。爆発が地形にダメージを与えるかどうかを設定するのに使用されます。

  • 非表示
    複製されていません
    並列読み取り
  • 並列読み取り

    このプロパティは、Explosion の中心の位置です。ワールドスペースで定義され、Explosion 親の影響を受けません。

  • 並列読み取り

    パーティクル効果の速度を制御する 0 から 1 の値。

  • 並列読み取り

    このプロパティは、Explosion の視覚効果が表示されるかどうかを決定します。

イベント

  • Hit(part : BasePart,distance : number):RBXScriptSignal

    ファイアが が自分の 内に をヒットすると発動します。部品からの距離と部品をヒットした部分を返します。

プロパティ

BlastPressure

並列読み取り

BaseParts に捕まえられた力の量を決定するために使用されます。Explosion.BlastRadius に捕まえられた力の量を決定するために使用されます。

現在適用されている力レベルは、Explosion.Position からの距離によって変化しません。未固定の BaseParts は、爆発半径内にある限り、距離に関係なく同じように速度が上昇します。

爆発圧は、爆発による部品の加速を決定します。ジョイントが壊れた程度を決定しません。When Explosion.DestroyJointRadiusPercent が 1 と同じになると、Explosion.BlastRadius のパーツ間のすべてのジョイントが破壊され、爆発圧力が 0 より大きい場合があります。

爆発圧力も、Terrain に与えられるダメージ量を決定しません。提供された爆発圧力が 0 より大きい場合、Explosion.ExplosionType は爆発タイプの枚数に設定されず、クレーターのサイズが作成されたクレーターのサイズを決定するのは、Explosion.BlastRadius だけです。

爆発圧を 0 に設定すると、爆発の効果が排除され、開発者が Explosion.Hit イベントを使用して爆発のカスタム動作をプログラミングしたいときに便利です。

コードサンプル

This sample contains a simple function that creates a custom explosion. The custom explosion will not break joints as Explosion.DestroyJointRadiusPercent is equal to 0. This means Humanoids will not be instantly killed as their neck joints are broken. In this example explosion.BlastPressure is equal to zero so as not to apply force or damage terrain but this can be changed.

The Explosion.Hit event is used to listen for contact. Once contact has been made the code will look for the parent model of the BasePart hit by the explosion. If that model exists, hasn't already been damaged and has a Humanoid in it damage will be applied based on distance from the explosion's origin.

Custom Explosion

local function customExplosion(position, radius, maxDamage)
local explosion = Instance.new("Explosion")
explosion.BlastPressure = 0 -- this could be set higher to still apply velocity to parts
explosion.DestroyJointRadiusPercent = 0 -- joints are safe
explosion.BlastRadius = radius
explosion.Position = position
-- set up a table to track the models hit
local modelsHit = {}
-- listen for contact
explosion.Hit:Connect(function(part, distance)
local parentModel = part.Parent
if parentModel then
-- check to see if this model has already been hit
if modelsHit[parentModel] then
return
end
-- log this model as hit
modelsHit[parentModel] = true
-- look for a humanoid
local humanoid = parentModel:FindFirstChild("Humanoid")
if humanoid then
local distanceFactor = distance / explosion.BlastRadius -- get the distance as a value between 0 and 1
distanceFactor = 1 - distanceFactor -- flip the amount, so that lower == closer == more damage
humanoid:TakeDamage(maxDamage * distanceFactor) -- TakeDamage to respect ForceFields
end
end
end)
explosion.Parent = game.Workspace
-- Roblox removes explosions after a few seconds, but does not destroy them.
-- To ensure our .Hit connection gets disconnected, destroy the explosion once it's removed.
explosion.AncestryChanged:Connect(function()
if not explosion.Parent then
explosion:Destroy()
end
end)
end
customExplosion(Vector3.new(0, 10, 0), 12, 50)

BlastRadius

並列読み取り

このプロパティは、Explosion の半径をスタッドで決定します。このプロパティは、0から100の間の任意の値を受け入れます。

この半径は、爆発の視覚サイズではなく、爆発の効果エリアを決定します。爆発の視覚効果のサイズは、爆発半径が 0 であっても、同じです。

BaseParts 爆発半径内では、爆発に影響を受けます。つまり、if Explosion.BlastPressure が 0 より大きい場合、力がパーツに適用されます。爆発半径内でジョイントが壊れる程度は、Explosion.DestroyJointRadiusPercentによります。Explosion.Hit は、半径内のすべての BasePart に発射します。

BaseParts は、範囲内にあるかどうかにかかわらず、Explosion.BlastRadius 内で考慮されます。範囲内にあるかどうかは部分的にしか判断できません。

コードサンプル

This code sample includes a brief snippet that creates a large explosion in the game at 0, 10, 0.

Explosion Instantiation

local explosion = Instance.new("Explosion")
explosion.BlastRadius = 60
explosion.ExplosionType = Enum.ExplosionType.Craters -- damages terrain
explosion.Position = Vector3.new(0, 10, 0)
explosion.Parent = workspace

DestroyJointRadiusPercent

並列読み取り

0から1の間の Explosion.BlastRadius の割合を設定し、すべてのジョイントが破壊される領域を設定するために使用されます。この範囲外のものは、Explosion フォースが適用されるだけです。

たとえば、Explosion.BlastRadius が 100 に設定され、DestroyJointRadiusPercent が 0.5 に設定されている場合、50スタッドの範囲内のすべてのジョイントが壊れます。50から100スタッドの間のジョイントは破壊されませんが、Explosion 力は依然としてBasePartsに適用されます。

このプロパティでは、開発者が DestroyJointRadiusPercent を 0 に設定して、Explosions 「致命的でない」を Humanoids にすることができます。これは、キャラクターが Explosion に接触すると、首の関節が壊れないことを意味します。

コードサンプル

This sample includes an example of how Explosions can be made non lethal to player characters.

Non lethal explosions

local function onDescendantAdded(instance)
if instance:IsA("Explosion") then
local explosion = instance
explosion.DestroyJointRadiusPercent = 0
local destroyJointRadiusPercent = 1
explosion.Hit:Connect(function(part, distance)
-- check the part is in range to break joints
if distance <= destroyJointRadiusPercent * explosion.BlastRadius then
-- make sure the part does not belong to a character
if not game.Players:GetPlayerFromCharacter(part.Parent) then
part:BreakJoints()
end
end
end)
end
end
workspace.DescendantAdded:Connect(onDescendantAdded)

This sample contains a simple function that creates a custom explosion. The custom explosion will not break joints as Explosion.DestroyJointRadiusPercent is equal to 0. This means Humanoids will not be instantly killed as their neck joints are broken. In this example explosion.BlastPressure is equal to zero so as not to apply force or damage terrain but this can be changed.

The Explosion.Hit event is used to listen for contact. Once contact has been made the code will look for the parent model of the BasePart hit by the explosion. If that model exists, hasn't already been damaged and has a Humanoid in it damage will be applied based on distance from the explosion's origin.

Custom Explosion

local function customExplosion(position, radius, maxDamage)
local explosion = Instance.new("Explosion")
explosion.BlastPressure = 0 -- this could be set higher to still apply velocity to parts
explosion.DestroyJointRadiusPercent = 0 -- joints are safe
explosion.BlastRadius = radius
explosion.Position = position
-- set up a table to track the models hit
local modelsHit = {}
-- listen for contact
explosion.Hit:Connect(function(part, distance)
local parentModel = part.Parent
if parentModel then
-- check to see if this model has already been hit
if modelsHit[parentModel] then
return
end
-- log this model as hit
modelsHit[parentModel] = true
-- look for a humanoid
local humanoid = parentModel:FindFirstChild("Humanoid")
if humanoid then
local distanceFactor = distance / explosion.BlastRadius -- get the distance as a value between 0 and 1
distanceFactor = 1 - distanceFactor -- flip the amount, so that lower == closer == more damage
humanoid:TakeDamage(maxDamage * distanceFactor) -- TakeDamage to respect ForceFields
end
end
end)
explosion.Parent = game.Workspace
-- Roblox removes explosions after a few seconds, but does not destroy them.
-- To ensure our .Hit connection gets disconnected, destroy the explosion once it's removed.
explosion.AncestryChanged:Connect(function()
if not explosion.Parent then
explosion:Destroy()
end
end)
end
customExplosion(Vector3.new(0, 10, 0), 12, 50)

ExplosionType

並列読み取り

このプロパティは、ExplosionTerrain とどのように相互作用するかを決定します。それは Enum.ExplosionType の値であり、3つのオプションの 1つに設定できます。

  • ノクラーがない - 爆発は地形にダメージを与えない
  • クレーター - 爆発は、地形にクレーターを作成します
  • クレーターと破片 - 重複し、クレーターと同じ動作をする

爆発タイプが Terrain でクレーターを作成するように設定されている場合、クレーターの半径は約 Explosion.BlastRadius に等しい。クレーターは、水以外のすべての Terrain 材料で作成されます。クレーターのサイズは、素材に影響を受けませんが、一部の素材は他の素材よりも粗い縁を作ります。

コードサンプル

This code sample includes an example of how the Explosion.ExplosionType property can be used to stop Explosions from damaging terrain. It is recommended to set the ExplosionType to NoCraters at the point of Explosion instantiation, but if that is not practical the code below will work.

Stop Explosions from Damaging Terrain

local function onDescendantAdded(instance)
if instance:IsA("Explosion") then
instance.ExplosionType = Enum.ExplosionType.NoCraters
instance:GetPropertyChangedSignal("ExplosionType"):Connect(function()
instance.ExplosionType = Enum.ExplosionType.NoCraters
end)
end
end
workspace.DescendantAdded:Connect(onDescendantAdded)

LocalTransparencyModifier

非表示
複製されていません
並列読み取り

Position

並列読み取り

このプロパティは、Explosion の中心の位置です。ワールドスペースで定義され、Explosion 親の影響を受けません。

は、爆発の位置の スタッド内にある場合、影響を受けます。

爆発の効果は瞬時です。これは、爆発の位置が設定された後でも変更できるものの、2つの異なる領域に影響を与えることはできないということです。爆発が「爆発」した後、Workspace の子孫に親を付けた直後に、再びそうしない。爆発の視覚効果が移動する場合がありますが、効果はありません。

このため、開発者が異なる位置に爆発を表示したい場合は、新しい爆発を作成する必要があります。

コードサンプル

This code sample includes a brief snippet that creates a large explosion in the game at 0, 10, 0.

Explosion Instantiation

local explosion = Instance.new("Explosion")
explosion.BlastRadius = 60
explosion.ExplosionType = Enum.ExplosionType.Craters -- damages terrain
explosion.Position = Vector3.new(0, 10, 0)
explosion.Parent = workspace

TimeScale

並列読み取り

パーティクル効果の速度を制御する 0 から 1 の値。1では通常速度で実行し、0.5では半速で実行し、0では時間が凍結します。

Visible

並列読み取り

このプロパティは、Explosion の視覚効果が表示されるかどうかを決定します。

Visible が false に設定されると、爆発はまだ に影響し、唯一の違いは見えないことです。

このプロパティの使用法の 1つは、開発者が ParticleEmitter を使用して独自のカスタム爆発効果を作成し、デフォルトの Explosion 機能を維持することです。

コードサンプル

This sample includes a function that will create an Explosion but replace the default Explosion visuals but those of a ParticleEmitter.

Explosion Custom Visuals

local function customExplosion(position)
local explosion = Instance.new("Explosion")
explosion.Position = position
explosion.Visible = false
local attachment = Instance.new("Attachment")
attachment.Position = position
attachment.Parent = workspace.Terrain
local particleEmitter = Instance.new("ParticleEmitter")
particleEmitter.Enabled = false
particleEmitter.Parent = attachment
particleEmitter.Speed = NumberRange.new(5, 30)
particleEmitter.SpreadAngle = Vector2.new(-90, 90)
explosion.Parent = workspace
particleEmitter:Emit(20)
task.delay(5, function()
if attachment then
attachment:Destroy()
end
end)
end
customExplosion(Vector3.new(0, 10, 0))

方法

イベント

Hit

ファイアが が自分の 内に をヒットすると発動します。部品からの距離と部品をヒットした部分を返します。

の効果は障害物によって中断されないことに注意してください、これは、他のパーツの後ろにシールドされているパーツが、 シールドされているにもかかわらず、攻撃を受け続けることを意味します。

このイベントは、Explosion.BlastPressure がゼロに等しいときにも発動します。これは、開発者が爆発の影響を排除して、爆発の独自のカスタム動作をプログラミングできることを意味します BaseParts および Terrain

このイベントは、すべての BasePart ヒットに発射することに注意してください。これは、同じプレイヤーキャラクターに複数回発砲できる(キャラクター Model は複数のパーツで構成されている)ことを意味します。このため、Explosion.Hit イベントを使用してカスタムダメージを処理するときは、キャラクターがすでに Explosion にヒットしたかどうかをチェックすることを推奨します。

パラメータ

part: BasePart

The BasePartExplosion にヒットしました。

distance: number

ヒットからの距離 Explosion.Position


コードサンプル

This sample contains a simple function that creates a custom explosion. The custom explosion will not break joints as Explosion.DestroyJointRadiusPercent is equal to 0. This means Humanoids will not be instantly killed as their neck joints are broken. In this example explosion.BlastPressure is equal to zero so as not to apply force or damage terrain but this can be changed.

The Explosion.Hit event is used to listen for contact. Once contact has been made the code will look for the parent model of the BasePart hit by the explosion. If that model exists, hasn't already been damaged and has a Humanoid in it damage will be applied based on distance from the explosion's origin.

Custom Explosion

local function customExplosion(position, radius, maxDamage)
local explosion = Instance.new("Explosion")
explosion.BlastPressure = 0 -- this could be set higher to still apply velocity to parts
explosion.DestroyJointRadiusPercent = 0 -- joints are safe
explosion.BlastRadius = radius
explosion.Position = position
-- set up a table to track the models hit
local modelsHit = {}
-- listen for contact
explosion.Hit:Connect(function(part, distance)
local parentModel = part.Parent
if parentModel then
-- check to see if this model has already been hit
if modelsHit[parentModel] then
return
end
-- log this model as hit
modelsHit[parentModel] = true
-- look for a humanoid
local humanoid = parentModel:FindFirstChild("Humanoid")
if humanoid then
local distanceFactor = distance / explosion.BlastRadius -- get the distance as a value between 0 and 1
distanceFactor = 1 - distanceFactor -- flip the amount, so that lower == closer == more damage
humanoid:TakeDamage(maxDamage * distanceFactor) -- TakeDamage to respect ForceFields
end
end
end)
explosion.Parent = game.Workspace
-- Roblox removes explosions after a few seconds, but does not destroy them.
-- To ensure our .Hit connection gets disconnected, destroy the explosion once it's removed.
explosion.AncestryChanged:Connect(function()
if not explosion.Parent then
explosion:Destroy()
end
end)
end
customExplosion(Vector3.new(0, 10, 0), 12, 50)