From 5b628baedf0ab520444e4f34c1fd9ddb643195e6 Mon Sep 17 00:00:00 2001 From: Glence Date: Thu, 2 Feb 2023 11:16:56 +0800 Subject: [PATCH] changes breakable to only minus count on items --- Assets/Scripts/Gameplay/Item/SC_Breakable.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Gameplay/Item/SC_Breakable.cs b/Assets/Scripts/Gameplay/Item/SC_Breakable.cs index 14ee4477..964a8b99 100644 --- a/Assets/Scripts/Gameplay/Item/SC_Breakable.cs +++ b/Assets/Scripts/Gameplay/Item/SC_Breakable.cs @@ -47,7 +47,8 @@ public class Breakable : Script if (rb.LinearVelocity.GetSqrMagnitude() > threshHold) { isBreak = true; - GameManager.Instance.totalItemCount -= 1; + if(GameObject.GetScript()) + GameManager.Instance.totalItemCount -= 1; } } protected override void onTriggerEnter(CollisionInfo info) @@ -61,12 +62,14 @@ public class Breakable : Script { item.SetActive(true); item.GetComponent().GlobalPosition = trans.LocalPosition + item.GetComponent().LocalPosition; + if (item.GetScript()) + GameManager.Instance.totalItemCount += 1; GameObject gO = item; gO.Parent = GameObject.Null; } isBreak = false; Audio.PlaySFXOnce2D("event:/Props/impact_break"); - Owner.SetActive(false); + GameObject.SetActive(false); } } \ No newline at end of file