From 1af34a21fa9ffe6c54dc3e87e83bf4d97609068d Mon Sep 17 00:00:00 2001 From: maelstrom Date: Fri, 30 May 2025 02:19:44 +0200 Subject: [PATCH] feat(physics): last part of model that falls off world destroys model too --- core/src/objects/workspace.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/objects/workspace.cpp b/core/src/objects/workspace.cpp index 4b830fe..8b2085e 100644 --- a/core/src/objects/workspace.cpp +++ b/core/src/objects/workspace.cpp @@ -151,7 +151,12 @@ void Workspace::PhysicsStep(float deltaTime) { // Destroy fallen parts if (part->cframe.Position().Y() < this->fallenPartsDestroyHeight) { + auto parent = part->GetParent(); part->Destroy(); + + // If the parent of the part is a Model, destroy it too + if (parent.has_value() && parent.value()->IsA("Model")) + parent.value()->Destroy(); } } }