How could I make a explosion radius for a nuke?
Basiclly a cylinder that expands and turns everything it touches into rust.
I already tried doing it by using :GetTouchingParts(), but it was extremly laggy.
And of course I cant really use the Touches event because the explosion radius would be anchored.
you would have to loop through the children of workspace, measure the distance between the value and the nuke, if its less than 50 for example then change the material to rust
Maybe you could loop through every part in the Workspace, and calculate the time it takes for the nuke to reach it using the distance from ground zero and the speed of the explosion. So you only have to loop through all of the parts once.
Didn’t you read? That’s because the explosion radius is anchored, and .Touched only works on parts that are part of a physics movement. An anchored part changing size is not a physics movement.
I’ve got another idea: Store a list of each part’s distance from ground zero, and the part itself. Then, while the nuke is running, iterate through the list every frame. If the part is inside the expanding blast radius, then change its look and delete the part from the list.
I’ve tried this and it works well. I put an array of nine Crossroads and the Effiel Tower and in the beginning it runs at around 16 FPS, I think. Here is a video showing this: nuke.wmv (4.4 MB)
EDIT: i somehow forgot the post the code and then i closed the place with the code and it’s gone forever now
do this everytime you resize or as you are resizing
then iterate through them and do what you need to the parts
local Part = workspace.Nuke
for i, touched in ipairs(Part:GetTouchingParts()) do -- this will get table of parts it is touching and check if the material is set to corrod if not it sets it
if touched.Material ~= Enum.Material.CorrodedMetal then
touched.Material = Enum.Material.CorrodedMetal
end
end
if you are using a not collide part then you will need to setup a function with a temp connection to Part.Touched then call the gettouchingparts on the part
then diconnect it and send results back