Explosion not detecting part

#1

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.

0 Likes

#2

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?

0 Likes

#3

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.

3 Likes

Does anyone have any alternative to region3?
#4

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?

0 Likes

#5

Some notes:

  • There’s no need to delay destruction! You can destroy immediately.
  • Don’t parent until you’ve set all properties. This is a significant performance cost.
  • The part must be unanchored
  • This only detects parts that are unanchored and CanCollide true.
  • Disclaimer: this is still technically a hack. It may stop working.

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
1 Like

#6

Explanation should you want one:

1 Like