Hi, so I just noticed that the Touched event isn’t working reliably with my bombs. So, I made a bomb tool that creates an explosion part sphere, and that sphere expands in all directions, then fades out. If players touch that sphere, it’ll kill them. There’s also a freeze bomb that freezes players that collide with the explosion. It creates a block around the player’s character, also anchoring the player’s character as well.
I noticed if somebody throws a damage bomb, and if players collide with it but they’re currently frozen, they won’t take any damage from it.
In my experience with using distance from character, you have to get the value every time the humanoid moves so it can get quite hard to deal with debounce wise.
Do you think this wouldn’t be that expensive to do though? The only way I see this working is to create Region3’s every time the loop runs to resize the explosion, which is about 30 times.
To my understanding you can expand the region using ExpandToGrid, I do not know if it works the way that you want it to though. Here is where I got this information:
If I’m not mistaken, Region3 is more expensive. You could use DistanceFromCharacter or Magnitude, which you should only have to get once for everyone in the bomb blast radius
Clone the script 2 times so the the touched is more precise? Put the touched event in a render stepped(performance eating probably)? Not sure if both methods work.
Cloning the script would not fix anything, there’s still the possibility that both scripts won’t run or that both scripts will run at the same time (not a good thing!). If this is a costly script, having both scripts run at once would just be a bad idea.
RenderStepped has nothing to do with Touched…? RenderStepped is used in cases of precision (think shooting games), not in the cases of a Touched event. The event would still fire even if the player isn’t touching any of the parts that you want it to touch, and if the resource is costly, it’d just cause more lag to the player.
local bomb = workspace.Bomb
function getTouchingParts(bomb)
local connection = bomb.Touched:Connect(function() end) -- trick to make :GetTouchingParts() work with cancollide off parts
local touchingParts = bomb:GetTouchingParts()
connection:Disconnect()
return touchingParts
end
it works with well with spheres and anchored parts, I think it works nicely performance wise too
Personally I’d use GetTouchingParts over Touched in this case because it would be easier to add effects like pulsing damage
The same applies with a ray cast since your just checking the distance and obstacles. If you don’t want obstacles to block the bomb though, you could just use DistanceFromCharacter. But rays will let you catch the case of their arm or something being in the radius when the measure point isn’t.
Since the bomb size is increasing, you might need to check a few more times if it’s a slow enough speed to matter, but you would need to do that with any method you used unless it’s a connection. However, if it’s going that slow and it’s visible you would be able to see if your character is touching it, so GetTouchingParts would give you more visually accurate results if you fire it enough, though the difference would be small.
Yes you would, but I’m not sure where this question is coming from. Are you concerned about the expense? It’s not expensive or performance hitting at all. You can fire hundreds of rays, provided their lengths are short, every frame.