From 5d4c030d9b6b137ece5018a7db78b6169d75a28a Mon Sep 17 00:00:00 2001 From: trotFunky Date: Thu, 19 Sep 2019 11:38:00 +0200 Subject: [PATCH] Bullet despawn on leaving view --- Assets/Scripts/Bullet.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Assets/Scripts/Bullet.cs b/Assets/Scripts/Bullet.cs index 0ef04c7..69bf192 100644 --- a/Assets/Scripts/Bullet.cs +++ b/Assets/Scripts/Bullet.cs @@ -46,4 +46,9 @@ public class Bullet : MonoBehaviour { Destroy(gameObject); } + + private void OnBecameInvisible() + { + Destroy(gameObject); + } }