폭발 내의 BaseParts 내 BlastRadius 내에 적용된 힘은 파츠 및 킬을 중지
경험이 실행되는 동안 데이터 모델의 어느 곳에서든 Explosion이 부모로 지정되면 즉시 실행이 중단되고 몇 초 내에 부모가 다시 지정됩니다. 이 경우 Class.Instance:Destroy()</
참고 Explosion 은 폭발 시각적 개체를 생성하고 물리적/손상 효과를 미치려면 Workspace 의 하위인 해야 합니다.
폭발 효과
Humanoids 는 폭발로 죽습니다, 폭발은 캐릭터의 Model 목 관절을 부서뜨리기 때문에 폭발 킬 효과를 보호합니다. ForceField 를 모델에 부모로 지정하면 모든 자식을 폭발 킬 효과로부터 보호할
Class.BasePart|BaseParts 을 Humanoids 와 함께 부서뜨리거나 자체 수식을 사용하여 피해를 입히려면 이 값을 0으로 설정하고 Class.Explosion.DestroyJointRadiusPercent|Destroy
폭발은 또한 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.Explosion.BlastRadius에 갇힌 Explosion.BlastRadius 에 적용할 힘의 양을 결정하는 데 사용됩니다.
이 속성은 스터드 단위의 Explosion 의 반경을 결정합니다. 이 반경은 폭발의 영향 영역을 결정하며 폭발의 시각적 개체 크기가 아닙니다.
Class.Explosion.BlastRadius 의 비율을 설정하여 모든 연결을 파괴하는 데 사용됩니다. 이 범위 내의 모든 것은 Explosion 힘만 적용됩니다.
이 속성은 Explosion 이 지형과 상호 작용하는 방법을 결정합니다. 폭발이 지형에 피해를 입는지 여부를 설정하는 데 사용됩니다.
이 속성은 세계 공간의 중심입니다. Explosion의 부모에 의해 영향을 받지 않습니다.
입자 효과 속도를 조정하는 값은 0에서 1 사이입니다.
이 속성은 Explosion의 시각적 효과가 표시되는지 여부를 결정합니다.
이벤트
Class.Explosion.BlastRadius 내의 BasePart 에 적중하면 Explosion.BlastRadius 가 발생합니다. 1>Class.Explosion.Fire1> 와 함께 부품이 부품의 거리를 반환합니다.
속성
BlastPressure
Class.Explosion.BlastRadius에 갇힌 Explosion.BlastRadius 에 적용할 힘의 양을 결정하는 데 사용됩니다.
현재 이 수준의 힘은 Explosion.Position 에서 적용되는 것이 아닙니다. 고정되지 않은 BaseParts 는 모두 동일하게 폭발 반경 내에서 멀리 가속됩니다.
폭발 압력은 폭발로 인한 부품의 가속을 결정합니다. 공의 부서졌는 정도를 결정하지 않습니다. Explosion.DestroyJointRadiusPercent 가 1일 때 모든 공의 부서졌는 정도가 제공되지 않습니다. 공의 부서졌는 정도가 0일 때 모
폭발 압력은 또한 Terrain 에 제공되는 폭발 압력을 결정하지 않습니다. 제공된 폭발 압력이 0보다 크면 Explosion.ExplosionType 은 크레이터 크기를 결정하는 데
폭발 압력을 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(이 BlastRadius가 0인 경우에도)가 동일합니다.
BaseParts 내의 폭발에 대해 폭발의 영향을 받습니다. 즉, if Explosion.BlastPressure 가 0보다 크면 부품에
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
Class.Explosion.BlastRadius 의 비율을 설정하여 모든 연결을 파괴하는 데 사용됩니다. 이 범위 내의 모든 것은 Explosion 힘만 적용됩니다.
예를 들어, Explosion.BlastRadius 가 100로 설정되어 있고 Explosion 가 0.5로 설정되어 있으면 모든 50 스터드 내의 연결이 파괴됩니다. Class.BasePart|BaseParts</
이 속성을 사용하면 개발자가 Explosions 를 Humanoids 로 만들 수 있도록 파괴 공간 전도도 백분율을 0으로 설정하면 목 관절이 부서지지 않습니다. 이는 캐릭터가 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
이 속성은 Explosion 이 Terrain 과 어떻게 상호 작용할지 결정합니다. 그것은 열거형 폭발 유형 값이며 세 가지 옵션 중 하나를 설정할 수 있습니다.
- NoCraters - 폭발로 인한 지형 손상이 없습니다.
- 화산 - 폭발은 지형에 화산을 생성합니다.
- 화산과 잔해 - 중복, 화산과 동일하게 동작합니다
폭발 유형이 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의 부모에 의해 영향을 받지 않습니다.
BaseParts 이 경우 폭발의 위치 내에 있는 Explosion 이 영향을 받습니다.
폭발의 효과는 즉각적입니다. 즉, 폭발 위치가 설정된 후에도 두 개의 다른 영역에 영향을 미칠 수 있지만 이 효과는 다시 설정되지 않습니다. 폭발이 일어난 후 즉시 부모가 된 후손에게 부모가 될 수 있지만 이 효과는 �
이 이유로 개발자가 폭발을 다른 위치에 표시하려면 새로운 폭발을 생성해야 합니다.
코드 샘플
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의 시각적 효과가 표시되는지 여부를 결정합니다.
Visible 이 false로 설정되면 폭발은 여전히 BaseParts 의 Explosion.BlastRadius 에 영향을 미칩니다. 유일한 차이점은 보이지 않습니다.
이 속성의 하나의 사용은 개발자가 기본 Class.Explosion 기능을 유지하면서 ParticleEmitter를 사용하여 자신만의 사용자 정의 폭발 효과를 만드는 것입니다.
코드 샘플
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.Fire1> 와 함께 부품이 부품의 거리를 반환합니다.
Class.Explosion 의 효과는 장애물로 인해 손상되지 않지만, 다른 부품이 손상되더라도 여전히 부품이 다른 부품 뒤에 있는 경우 여전히 손상됩니다. BasePart 이 손상되더라도 안착된 경우 여전히 효과가 적용됩니다.
이 이벤트는 또한 Explosion.BlastPressure 가 0인 경우에도 발생합니다. 즉, 개발자는 폭발에 대한 폭발의 영향을 제거하여 폭발에 대한 사용자 지정 동작을 프로그래밍할 수 있습니다. 이는 Class.BasePart|BaseParts 및 1>Class.Terr
이 이벤트는 모든 BasePart 히트에 대해 발생합니다. 즉, 동일한 플레이어 캐릭터(캐릭터 Model 이 여러 부분으로 구성되어 있음)에 대해 여러 번 발생할
매개 변수
Class.Explosion 에 의해 타격 된 Class.BasePart .
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)