What do you want to achieve? Keep it simple and clear!
I want to figure out how to make a DoomSpire tower be affected like they do in the original when a joint/weld is broken, either by an explosion or some other means.
What is the issue? Include screenshots / videos if possible!
I simply cannot figure out how I would go about that, I have an idea of what I want, for when a piece of the model is separated for it to just… Not float. I want everything above/below it to separate with it. For example, if I disconnected the tower into 3 pieces, each piece should then be affected by gravity. However, when trying this I’ve come to an issue where the model itself will just fall into the void, adding in a Primary Part to it just makes it so whenever the primary is unlinked, the whole thing goes with it. I want it to be suspended in the void without it doing that.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve looked far and wide at this point, writing my own code and even searching online and in the developer forums has not really shown any specific things for my use cases, only getting topics that do the opposite. (EX: How to make parts NOT affected by gravity)
My own system is rather messy, and is non-functional in a way I want it to be. I have already tried things like qPerfectionWeld and that just… doesn’t work either. I am at a loss, I just want the script to get the children of the model and do what I described, but it doesn’t really seem (at least to me) any easy ways to do this without refactoring or remodelling my whole spire from scratch.
Any ideas on how to approach this would be appreciated, as I’ve been tearing my hair out at this for a while now.
I think that the parts of your model is welded to one or few parts instead of being welded to the nearest neighbour part, make sure that parts are linked neighbourly
Mhm! That is what I tried, they were all welded to eachother, however I still had the issue with them either not collapsing once they are disconnected
OR
Simply falling into the void.
did you check what they were connected to? since only one conclusion comes to mind that one or few of the parts are connected to another section’s parts once you split them into 3 sections
As mentioned, they either fall into the void or simply collapse. I want to do it the way the orginal Doomspire brickbattle did it, I’m just not sure how to execute that.
no I understand what you meant by 3 sections, correct me if I understand correctly:
like doomspire is built of many parts, if the middle section is cut/destroyed and no parts connect the top and bottom then, the top falls, the bottom remains anchored
your problem is that if the mid section is cut, the whole tower still acts like as mid section wasnt cut, the top stays at the top, the bottom remains anchored
if thats the problem, then it is what I said, that maybe any one of the top part is welded to the any one of bottom section’s part
if ur using qPerfectionWeld, then that makes each part’s weld relative to the model itself, use roblox’s own weld
Ah, my mistake then, you are correct, that it is what I meant.
Its just because of the sheer amount of parts inside this model, trying to weld them all through a script has proven unviable. There still comes an issue with how do I keep it from falling into the void?
Anchoring it seems like the best option, the unanchoring it once the explosion instance’ Raycasts hit the parts, an applies the force. However; that wont affect them if they are seperated, how would I go about that? Should there be a singular root I anchor specifically?
yeah make a singular anchored root part that is unaffected by explosion, and weld the bottom parts of the tower to the root part, and it is definitely possible to weld adjacently through a script, it would go something like this:
local _parts = {} --all the parts
for i, p in _parts do
for j, p2 in _parts do
if (p.Position-p2.Position).Magnitude<p.Size.Magnitude+p2.Size.Magnitude then
--create weld constraint and add these two parts
end
end
end
Sorry for the wait, had to come up with something.
Would this be viable?
local TowerModel = script.Parent.TowerModel
local _parts = {}
for _, child in ipairs(TowerModel:GetChildren()) do
if child:IsA("BasePart") then
table.insert(_parts, child)
end
end
local function weldParts(part1, part2)
local weld = Instance.new("Weld")
weld.Part0 = part1
weld.Part1 = part2
weld.Parent = script.Parent.ROOT
end
spawn(function()
for i, p in ipairs(_parts) do
for j, p2 in ipairs(_parts) do
if i ~= j then
local distance = (p.Position - p2.Position).Magnitude
local sizeSum = (p.Size.Magnitude + p2.Size.Magnitude) / 2
if distance < sizeSum then
weldParts(p, p2)
wait(0.1)
end
end
end
end
end)
local TowerModel = script.Parent
local _parts = {}
for _, child in ipairs(TowerModel:GetChildren()) do
if child:IsA("BasePart") then
table.insert(_parts, child)
end
end
local function weldParts(part1, part2)
local weld = Instance.new("WeldConstraint")
weld.Part0 = part1
weld.Part1 = part2
weld.Parent = part1
end
spawn(function()
for i, p in ipairs(_parts) do
local _neighbours = workspace:GetPartBoundsInBox(p.CFrame, p.Size+Vector3.one)
for j, np in pairs(_neighbours) do
weldParts(p, np)
end
end
end)
I ended up trying this, and it actually exhausts the execution time, if I leave the tower unanchored, it doesn’t have the time to weld them all together at startup.
I will try your approach with the code you have given, but I may add in leaving the whole thing anchored until it finishes all the welds, then unanchoring.
Added the unanchoring part, it works perfectly now! Will mark you as the solution due to your use of a base for code! Much appreciated!
local TowerModel = script.Parent.TowerModel
local _parts = {}
for _, child in ipairs(TowerModel:GetChildren()) do
if child:IsA("BasePart") then
table.insert(_parts, child)
end
end
local function weldParts(part1, part2)
local weld = Instance.new("WeldConstraint")
weld.Part0 = part1
weld.Part1 = part2
weld.Parent = part1
end
spawn(function()
for i, p in ipairs(_parts) do
local _neighbours = workspace:GetPartBoundsInBox(p.CFrame, p.Size + Vector3.one)
for j, np in pairs(_neighbours) do
weldParts(p, np)
end
end
for _, part in ipairs(_parts) do
if part.Name == "TowerPart" then
part.Anchored = false
-- print("Unanchored Part")
end
end
end)