From 66dec3d98c13d14171590a45c38cdd433aa56f7d Mon Sep 17 00:00:00 2001 From: Teascade Date: Sun, 4 Aug 2019 02:10:18 +0300 Subject: [PATCH] make bullets go dissapear when hit something --- Assets/Scripts/Bullets/RevolverBullet.cs | 9 +++++++++ Assets/Scripts/Gun.cs | 8 -------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/Bullets/RevolverBullet.cs b/Assets/Scripts/Bullets/RevolverBullet.cs index be3ecc1..f3ecc57 100644 --- a/Assets/Scripts/Bullets/RevolverBullet.cs +++ b/Assets/Scripts/Bullets/RevolverBullet.cs @@ -15,5 +15,14 @@ namespace Saltosion.OneWeapon.Bullets { Body.velocity = Direction * 15; Body.rotation = Rot - 90; } + + void OnTriggerEnter2D(Collider2D collider) { + if (collider.GetComponent() != null) { + // don't hit the player! + return; + } + Destroy(gameObject); + Debug.Log("Boom!"); + } } } diff --git a/Assets/Scripts/Gun.cs b/Assets/Scripts/Gun.cs index cc8090c..c4562a0 100644 --- a/Assets/Scripts/Gun.cs +++ b/Assets/Scripts/Gun.cs @@ -10,14 +10,6 @@ namespace Saltosion.OneWeapon { private bool IsHeld = false; - void Start() { - - } - - void Update() { - - } - void OnTriggerEnter2D(Collider2D collider) { if (IsHeld) { return;