From 04f422deabcbc9d6d147e268b2288cd77625f718 Mon Sep 17 00:00:00 2001
From: Zenovore <agustinus.alexander17@gmail.com>
Date: Sat, 9 Apr 2022 18:02:46 +0700
Subject: [PATCH] add range

---
 Survival Shooter/Assets/Prefabs/Bullet.prefab    | 1 +
 Survival Shooter/Assets/Scripts/Bullet/Bullet.cs | 7 ++++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/Survival Shooter/Assets/Prefabs/Bullet.prefab b/Survival Shooter/Assets/Prefabs/Bullet.prefab
index 8407304..a6a42da 100644
--- a/Survival Shooter/Assets/Prefabs/Bullet.prefab	
+++ b/Survival Shooter/Assets/Prefabs/Bullet.prefab	
@@ -48,6 +48,7 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   speed: 10
   damage: 20
+  life: 1.1
 --- !u!114 &4583758620994889822
 MonoBehaviour:
   m_ObjectHideFlags: 0
diff --git a/Survival Shooter/Assets/Scripts/Bullet/Bullet.cs b/Survival Shooter/Assets/Scripts/Bullet/Bullet.cs
index c542a15..51f61f5 100644
--- a/Survival Shooter/Assets/Scripts/Bullet/Bullet.cs	
+++ b/Survival Shooter/Assets/Scripts/Bullet/Bullet.cs	
@@ -6,6 +6,7 @@ public class Bullet : MonoBehaviour
 {
     public float speed = 100.0f;
     public int damage = 20;
+    public float life = 1.1f;
 
     float timer;
     	Vector3 velocity;
@@ -39,9 +40,9 @@ public class Bullet : MonoBehaviour
 		timer += Time.deltaTime;
 
 		// Schedule for destruction if bullet never hits anything.
-		// if (timer >= life) {
-		// 	Dissipate();
-		// }
+		if (timer >= life) {
+      Destroy(gameObject);
+		}
 
         velocity = transform.forward;
 		velocity.y = 0;
-- 
GitLab