Explosion
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
爆発の BaseParts 内の BlastRadius 内の JointInstances と 2>
エクスペリエンスが実行されている間、データモデルのどこかに Explosion が親化されている場合、それは即座にトリガーされ、数秒間で親化されなくなります。この場合、Class.Instance:Destroy() ではなく、親化されたままの
注:Class.Explosion は、Workspace の子である必要があり、爆発ビジュアルがプレイされ、物理/ダメージ効果が影響を与えるためには、Class.Explosion が必要です。
爆発エフェクト
Humanoids は爆発により殺されます、爆発はキャラクターの Model の頸部の関節を破壊します。 ForceField をモデルに親指して、すべての子供を爆発キルエフェクトから保護します。
Class.BasePart|BaseParts を破壊したくない場合、またはHumanoids をダメージするための自分のフォーミュラを実装したい場合は、DestroyJointRadiusPercent
爆発は、Terrain にダメージを与えるためにも設定できます。これにより、ExplosionType プロパティを通じて、クレーターを作成できます。
爆発の効果は、 は 障害物によって破壊されることがあり、つまり、他のパーツ/地形の後ろにあるパーツ/地形のパーツ/地形のパーツ/地形のパーツ/地形のパーツ/地形のパーツ/地形のパーツ/地形のパーツ/地形のパーツ/地形のパーツ/地形のパーツ/地形のパーツ/地形のパーツ/地形のパーツ/地形のパーツ/地形のパーツ/地形のパーツ/地形のパーツ/
コードサンプル
This code sample includes a brief snippet that creates a large explosion in the game at 0, 10, 0.
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
概要
プロパティ
Class.BasePart|BaseParts を含む Explosion.BlastRadius の適用された力を決定します。
このプロパティは、Explosion のスタッドでの範囲を決定します。この範囲は、爆発のエリアの効果を決定し、爆発のビジュアルのサイズを決定しません。
Class.Explosion.BlastRadius の割合を設定し、Explosion の範囲内のすべての関節を破壊する。この範囲の外の任意のものは、Class.Explosion の強度のみを適用します。
このプロパティは、Explosion がTerrain とどのようにインタラクトするかを決定します。用于を設定して、爆発が地形にダメージを与えるかどうかを設定します。
このプロパティは、Explosion の中心の位置です。世界スペースに定義され、Explosion 親に影響されません。
パーティクルエフェクトの速度を制御する値が 0 から 1 の間です。
このプロパティは、Explosion のビジュアルエフェクトが表示されるかどうかを決定します。
イベント
Class.Explosion.BlastRadius 内の BasePart に当該すると、Explosion.BlastRadius 内のパーツが含まれて、パーツの距離から 1> Class.Explosion.Position1> までの距離を返します。パーツがヒットされたパーツの距離と、パーツからの距離を返します。
プロパティ
BlastPressure
Class.BasePart|BaseParts を含む Explosion.BlastRadius の適用された力を決定します。
現在、このレベルの強度は、Explosion.Position からの距離に基づいて変わりません。アンカーBasePartsは、爆発範囲内にある無論の距離を等しく離れます。
爆発によるパーツの加速度は決まります。Explosion.DestroyJointRadiusPercent は、関節の破壊度を決めません。Explosion.BlastRadius の内のすべての関節が破壊されると、Class.Explosion.DestroyJointRadius が破壊されます。2>Class.Explosion.DestroyJointRadius
爆弾圧力は、Terrain に与えられるダメージ量を決定しません。提供される爆弾圧力は、0 より大きいです、および Explosion.ExplosionType は、Explosion.BlastRadius で、作成
BlastPressure を 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.
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 内の爆発により、Explosion.BlastPressure が 0 以上になる場合、Explosion.DestroyJointRadiusPercent は、0> Class.BasePart
BaseParts は、Explosion.BlastRadius 内の範囲内にある場合でも、Class.BasePart|BaseParts として扱われます。
コードサンプル
This code sample includes a brief snippet that creates a large explosion in the game at 0, 10, 0.
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
Class.Explosion.BlastRadius の割合を設定し、Explosion の範囲内のすべての関節を破壊する。この範囲の外の任意のものは、Class.Explosion の強度のみを適用します。
たとえば、Explosion.BlastRadius が 100 に設定され、Explosion が 0.5 に設定されている場合、50 スタッドの範囲内の任意のジョイントは破壊されます。Class.BasePart|
このプロパティは、開発者が Explosions を Humanoids に設定することで、Explosion の頸部の関節が破壊されないようになります。これは、キャラクターが 1> Class.Explosion1> に
コードサンプル
This sample includes an example of how Explosions can be made non lethal to player characters.
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.
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
このプロパティは、Explosion が Terrain とどのようにインタラクトするかを決定します。これは、枚数であり、3つのオプションの 1 つに設定できます。
- NoCraters - 爆発による地形へのダメージはありません
- クレーター - 爆発は地形にクレーターを作成します
- CratersAndDebris - Redundant、Cratersと同じように動作します
ExplosionType が 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.
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 親に影響されません。
BaseParts は、Explosion が爆発の位置の Explosion.BlastRadius 内にある場合、影響を受けます。
爆発の効果は即座です。これは、爆発の位置が設定された後に位置を変更することができるため、2つの異なる領域に影響を与えることはできません。爆発が「起爆」した後、親になる子孫によってWorkspaceに移動すると、再びは行われません。一部の場合、爆発のビジュアルエ
この理由で、開発者が爆発を別の場所に表示するようにしたい場合は、新しい爆発を作成する必要があります。
コードサンプル
This code sample includes a brief snippet that creates a large explosion in the game at 0, 10, 0.
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
Visible
このプロパティは、Explosion のビジュアルエフェクトが表示されるかどうかを決定します。
[可視] が偽で設定されている場合、爆発はまだ BaseParts の Explosion.BlastRadius に影響しますが、唯一の違いは、それは見えないです。
このプロパティの 1つの使用例は、ParticleEmitter を使用して、デフォルトの Explosion 機能を維持しながら、自分のカスタムエクスプロージョンエフェクトを作成するためです。
コードサンプル
This sample includes a function that will create an Explosion but replace the default Explosion visuals but those of a ParticleEmitter.
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
Class.Explosion.BlastRadius 内の BasePart に当該すると、Explosion.BlastRadius 内のパーツが含まれて、パーツの距離から 1> Class.Explosion.Position1> までの距離を返します。パーツがヒットされたパーツの距離と、パーツからの距離を返します。
Class.Explosion の効果は、障害物によって中断されることはありません。これは、BasePart が障害物の後ろに接続されていても、パーツがClass.Explosion によって保護されている場合でも、パーツがヒットされることを意味します。
このイベントは、Explosion.BlastPressure が 0 であるときにも発生します。これは、開発者が爆発の影響を BaseParts と Terrain の両方に排除することで爆発のカスタムビーハブをプログラムできることを意味します。
このイベントは、BasePart のヒットごとに発生します。これは、キャラクター Model が複数のパーツで構成されているため、同じプレイヤーキャラクターのヒットで複数回発生する可能性があるためで
パラメータ
Class.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.
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)