However I am unsure how to get this desired affect. I could un anchor all the parts, but then it’d fall from player interference/etc.
Tried this, but everything just ended up falling apart straight away
for _, part in MapClone.Destructable:GetDescendants() do
if not part:IsA("BasePart") then
continue
end
local TouchingParts = part:GetTouchingParts()
for _, touchingPart in TouchingParts do
local WeldConstraint = Instance.new("WeldConstraint")
WeldConstraint.Part0 = part
WeldConstraint.Part1 = touchingPart
WeldConstraint.Parent = part
end
part.Anchored = false
end
I’m pretty sure :GetTouchingParts() doesn’t work for anchored parts.:GetTouchingParts() only works for overlapping parts, not for parts perfectly next to eachother.
You could replace it with :GetPartBoundsInBox() like so
local overlapParams = OverlapParams.new()
overlapParams.FilterType = Enum.RaycastFilterType.Blacklist
overlapParams.FilterDescendantsInstances = {part} -- ignore the part, so it doesn't weld to itself
local TouchingParts = workspace:GetPartBoundsInBox(
part.CFrame,
part.Size + Vector3.new(.01, .01, .01), -- add size so that it also finds parts that aren't overlapping
overlapParams
)
However this will assume that every part is a cuboid, welding wedges and other shapes that aren’t touching.
This is a very interesting topic, I’ve thought about it and came to a conclusion that using physics simulation is the best way. Try implementing everything without anchoring. Weld the model, then, if one “Leg” gets destroyed and It wont fall. In those disaster games they probably somehow mix the physics + anchoring/unanchoring. I can’t provide step by step guide, but think in that direction.