From 3c2ca26a994de14aa9d086ec0686c56223d25186 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Thu, 15 Jul 2021 15:59:28 +0200 Subject: [PATCH] Properly destroy brush model child game objects when clearing an entity's model. Fixes explosive barrels not disappearing when blown up. --- Assets/Scripts/Game/Entity.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Game/Entity.cs b/Assets/Scripts/Game/Entity.cs index bc1aea9..fe9f4b9 100644 --- a/Assets/Scripts/Game/Entity.cs +++ b/Assets/Scripts/Game/Entity.cs @@ -65,8 +65,10 @@ public class Entity } meshRenderer.enabled = false; - // TODO: not sure if this is the right way to unlink world sub-models - gameObject.transform.DetachChildren(); + for (int child = 0; child < gameObject.transform.childCount; ++child) + { + Object.Destroy(gameObject.transform.GetChild(child).gameObject); + } } public void SetAliasModel(AliasModel model)