Testing Explosion.rbxl (16.8 KB)
The following place demonstrates my issue. When I plant any explosion object in, and it hits a part in the Model, it should print where in the model that part is, however those specific parts are not being detected.
Testing Explosion.rbxl (16.8 KB)
The following place demonstrates my issue. When I plant any explosion object in, and it hits a part in the Model, it should print where in the model that part is, however those specific parts are not being detected.
This is very interesting. I wasn’t able to find a solution, but it seems that when I scale the ring in the repro down, explosion hits start being detected. For some reason, these explosions really hate big parts?
Explosion hit detection is based on magnitude. So large parts are not detected since position of the part is far off.
The work around is to create a new unanchored cancollide true sphere and use :GetTouchingParts() which works on ungrounded parts. Then immediately destroy. The Roblox RPG does this.
I’d you need anchored parts, or can collide parts it may be more difficult. Personally I use a raycasting method that raycasts in a randomly evenly distributed manner so I can calculate percent damage and/or exposure. This seems decently performant.
I am actually intrigued by the Sphere concept.
So if logic assumes to be right (Never assume kids)
local part = Instance.new("Part", workspace)
part.Shape = Enum.PartType.Ball
part.Size = Vector3.new(2,2,2) * obj.BlastRadius
part.CFrame = CFrame.new(obj.Position)
part.Anchored = true
part.CanCollide = true
part.Transparency = 1
for i,v in pairs(part:GetTouchingParts()) do
--Do Hit Logic
print(v.Parent)
end
delay(0.1, function()
part:Destroy()
end)
Should work in practice?
Some notes:
Example:
local part = Instance.new("Part")
part.Anchored = false
part.CanCollide = true
part.CFrame = CFrame.new(explosion.Position)
part.Shape = Enum.PartType.Ball
part.Size = Vector3.new(2, 2, 2) * explosion.BlastRadius)
part.Parent = workspace -- Maybe parent to camera on server so it doesn't even try to replicate. I don't _think_ this is an issue. I'm not sure.
local parts = part:GetTouchingParts()
part:Destroy()
for _, part in pairs(part:GetTouchingParts()) do
-- do Logic
end
Explanation should you want one: