feat(physics): last part of model that falls off world destroys model too

This commit is contained in:
maelstrom 2025-05-30 02:19:44 +02:00
parent 964c733f53
commit 1af34a21fa

View file

@ -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();
}
}
}