diff options
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); } } |