폭발은 폭발의 BaseParts 내에서 힘을 적용합니다.An explosion applies force to within the explosion's BlastRadius .이 힘은 부품 사이의 JointInstances 와 WeldConstraints 을 파괴하고 Humanoid 에 의해 보호되지 않는 문자를 죽입니다 ForceField .Constraints 폭발로 인해 부서지지 않습니다.
경험이 실행되는 동안 데이터 모델의 어딘가에서 Explosion가 부모로 지정되면 즉시 시작되고, 몇 초 내에 부모로부터 분리됩니다.이 경우 Instance:Destroy()로 파괴되지 않으므로 연결이 끊어지지 않고 부모가 잠겨지지 않습니다.모든 인스턴스와 마찬가지로, 강력한 참조를 유지하면 Explosion 가비지 수집되지 않습니다.
폭발 시각이 재생되고 물리적/손상 효과가 영향을 미치려면 Explosion 가 하위 요소여야 하는 점에 유의하십시오. Note that an must be a descendant of Workspace for the explosion visuals to play and the physical/damaging effects to have an impact.
폭발 효과
Humanoids 는 폭발로 인해 캐릭터 Model 목 관절이 파괴되면서 폭발로 죽습니다.모델에 부모 ForceField 를 지정하면 모든 자식이 폭발 처치 효과로부터 보호됩니다.
BaseParts에서 조인이 깨지지 않도록 하거나 Humanoids에 대한 자신의 수식을 구현하려는 경우, 폭발의 결과를 처리하기 위해 DestroyJointRadiusPercent를 0으로 설정하고 Hit 이벤트를 사용하는 것이 좋습니다.
폭발은 또한 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
요약
속성
BaseParts에 적용된 힘의 양을 결정하기 위해 사용됩니다. Explosion.BlastRadius에 캡처된 것.
이 속성은 스터드에서 Explosion의 반경을 결정합니다.이 반경은 폭발의 영향 범위를 결정하지만 폭발의 시각적 크기는 아닙니다.
모든 조인트가 파괴될 범위 내에서 0과 1 사이의 Explosion.BlastRadius 비율을 설정하는 데 사용됩니다.이 범위 외에 있는 모든 것은 단지 Explosion 힘만 적용됩니다.
이 속성은 Explosion 가 어떻게 상호 작용할지 결정합니다 Terrain . 폭발이 지형에 피해를 줄지 여부를 설정하는 데 사용됩니다.
이 속성은 Explosion의 중심 위치입니다. 세계 공간에서 정의되며 부모 Explosion의 영향을 받지 않습니다.
입자 효과의 속도를 제어하는 값은 0과 1 사이입니다.
이 속성은 Explosion 의 시각적 효과가 표시되는지 여부를 결정합니다.
이벤트
가 자신의 내에서 타격할 때 화재를 발생시킵니다. 부품의 거리와 함께 부품을 타격하여 반환합니다.
속성
BlastPressure
BaseParts에 적용된 힘의 양을 결정하기 위해 사용됩니다. Explosion.BlastRadius에 캡처된 것.
현재 적용되는 이 수준의 힘은 거리에 따라 달라지지 않습니다 Explosion.Position .고정되지 않은 BaseParts 는 폭발 반경 내에 있는 경우 거리와 상관없이 원천으로부터 동일하게 가속될 것입니다.
폭발 압력은 폭발로 인해 부품의 가속을 결정합니다.관절이 얼마나 부서졌는지를 결정하지 않습니다.When Explosion.DestroyJointRadiusPercent 가 1과 같으면 부품 사이의 모든 연결이 Explosion.BlastRadius 에서 BlastPressure가 0보다 크면 파괴됩니다.
폭발 압력은 또한 Terrain에 준 피해량을 결정하지 않습니다.제공된 폭발 압력이 0보다 크고 Explosion.ExplosionType 가 Enum.ExplosionType.NoCraters의 크레이터 크기가 생성된 크레이터의 크기는 전적으로 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.
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 사이의 모든 값을 허용합니다.
이 반경은 폭발의 영향 범위를 결정하지만 폭발의 시각적 크기는 결정하지 않습니다.폭발의 시각 효과 크기는 BlastRadius(폭발 반경이 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.
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.
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
이 속성은 가 어떻게 상호작용할지를 결정합니다. 그것은 Enum.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의 영향을 받지 않습니다.
는 폭발의 위치에서 스터드 내에 있으면 영향을 받을 것입니다.
폭발의 효과는 즉시적입니다.즉, 폭발의 위치가 설정된 후에도 변경될 수는 있지만 두 개의 다른 영역에 영향을 미칠 수는 없습니다.한 번 폭발이 '폭발'되었으면, 짧은 시간 후에 부모로부터 후손인 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 의 시각적 효과가 표시되는지 여부를 결정합니다.
가시성이 false로 설정되면 폭발은 여전히 에서 영향을 미치지만, 유일한 차이점은 보이지 않는다는 것입니다.
이 속성의 하나는 개발자가 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
가 자신의 내에서 타격할 때 화재를 발생시킵니다. 부품의 거리와 함께 부품을 타격하여 반환합니다.
Explosion의 효과는 장애물로 인해 방해받지 않으므로, 다른 부품 뒤에 있는 부품이 여전히 타격을 받을 것입니다. 만약 그들이 고정되어 있는 BasePart가 고정되어 있다면 말입니다.
이 이벤트는 Explosion.BlastPressure가 0과 같을 때에도 발생합니다.즉, 개발자는 폭발의 영향을 제거하여 폭발의 고유한 사용자 지정 동작을 프로그래밍할 수 있습니다 BaseParts 및 Terrain .
이 이벤트는 모든 BasePart 히트마다 발생합니다.즉, 동일한 플레이어 캐릭터에 대해 여러 번 발사할 수 있습니다(캐릭터 Model는 여러 부분으로 구성됨).이러한 이유로 Explosion.Hit 이벤트를 사용하여 사용자 지정 피해를 처리할 때 캐릭터가 이미 Explosion 에 타격을 받았는지 확인하기 위한 검사를 구현하는 것이 좋습니다.
매개 변수
히트의 거리가 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)