diff options
author | chai <chaifix@163.com> | 2022-04-04 23:17:40 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2022-04-04 23:17:40 +0800 |
commit | 109cf871ccd809cc38927a6b068a080ec9fd52a1 (patch) | |
tree | 7fe6a00f7ae97529afb908c060132cc8e8c6fc80 /AlienSurvival/Assets/Scripts/Test/TestBeamBullet.cs | |
parent | dab7fde2eda6bf2a4498fdd8ab76f27c4ea0a348 (diff) |
* test
Diffstat (limited to 'AlienSurvival/Assets/Scripts/Test/TestBeamBullet.cs')
-rw-r--r-- | AlienSurvival/Assets/Scripts/Test/TestBeamBullet.cs | 25 |
1 files changed, 12 insertions, 13 deletions
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); } } |