Explosion

사용되지 않는 항목 표시

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.

폭발은 폭발의 BaseParts 내에서 힘을 적용합니다.An explosion applies force to within the explosion's BlastRadius .이 힘은 부품 사이의 JointInstancesWeldConstraints 을 파괴하고 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를 통해 구성된 것처럼 분화를 생성합니다.

폭발의 효과는 장애물로 인해 방해되지 않으며, 다른 부품/지형 뒤에 있는 부품/지형이 여전히 영향을 받는다는 점에 유의하십시오.

코드 샘플

이 코드 샘플에는 0, 10, 0에서 게임에서 큰 폭발을 일으키는 간략한 스니펫이 포함되어 있습니다.

폭발 즉시화

local explosion = Instance.new("Explosion")
explosion.BlastRadius = 60
explosion.ExplosionType = Enum.ExplosionType.Craters -- 지형 손상
explosion.Position = Vector3.new(0, 10, 0)
explosion.Parent = workspace

요약

속성

이벤트

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

    가 자신의 내에서 타격할 때 화재를 발생시킵니다. 부품의 거리와 함께 부품을 타격하여 반환합니다.

속성

BlastPressure

병렬 읽기

코드 샘플

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

병렬 읽기

코드 샘플

폭발 즉시화

local explosion = Instance.new("Explosion")
explosion.BlastRadius = 60
explosion.ExplosionType = Enum.ExplosionType.Craters -- 지형 손상
explosion.Position = Vector3.new(0, 10, 0)
explosion.Parent = workspace

DestroyJointRadiusPercent

병렬 읽기

코드 샘플

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)
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

병렬 읽기

코드 샘플

폭발로 인한 지형 손상 방지

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

병렬 읽기

코드 샘플

폭발 즉시화

local explosion = Instance.new("Explosion")
explosion.BlastRadius = 60
explosion.ExplosionType = Enum.ExplosionType.Craters -- 지형 손상
explosion.Position = Vector3.new(0, 10, 0)
explosion.Parent = workspace

TimeScale

병렬 읽기

Visible

병렬 읽기

코드 샘플

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

매개 변수

part: BasePart
distance: number

코드 샘플

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)