From 109cf871ccd809cc38927a6b068a080ec9fd52a1 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 4 Apr 2022 23:17:40 +0800 Subject: * test --- .../Assets/Scripts/Test/TestBeamBullet.cs | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'AlienSurvival/Assets/Scripts/Test/TestBeamBullet.cs') diff --git a/AlienSurvival/Assets/Scripts/Test/TestBeamBullet.cs b/AlienSurvival/Assets/Scripts/Test/TestBeamBullet.cs index d5d0476..17d0005 100644 --- a/AlienSurvival/Assets/Scripts/Test/TestBeamBullet.cs +++ b/AlienSurvival/Assets/Scripts/Test/TestBeamBullet.cs @@ -15,7 +15,10 @@ public class TestBeamBullet : MonoBehaviour void Dead() { - GameObject.Destroy(this.gameObject); + if (this.gameObject) + { + GameObject.Destroy(this.gameObject); + } } // Update is called once per frame @@ -28,25 +31,21 @@ public class TestBeamBullet : MonoBehaviour private void OnTriggerEnter2D(Collider2D collision) { - GameObject go = collision.attachedRigidbody.gameObject; + GameObject go = collision.gameObject; - if(go.CompareTag("device")) + if (!go.CompareTag("enemy")) { return; } + + GameObject.Destroy( collision.gameObject); - if(go.CompareTag("bullet")) + //this.gameObject.SetActive(false); + + if (this.gameObject) { - return; + GameObject.Destroy(this.gameObject); } - - //Debug.Log("hit"); - - GameObject.Destroy( collision.attachedRigidbody.gameObject); - - this.gameObject.SetActive(false); - - GameObject.Destroy(this.gameObject); } } -- cgit v1.1-26-g67d0