I’m wanting to allow a map to naturally get destroyed as parts are removed/destroyed through gameplay.
So say if I have a tower

and during the game, bottom 3 legs get destroyed. Naturally, it should topple right over.
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
1 Like
Could you show a video of what’s happening currently?
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.
I need something that’ll weld any and all part types including meshes. If their bounding box is touching a part, it needs to weld
Just tried this and it doesn’t work. Parts just collapsed straight away, and player can push parts over
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.