From bd780c918f3a5f90cf1c490aa06ed4f637ff8726 Mon Sep 17 00:00:00 2001 From: Petteri <jupean@utu.fi> Date: Sun, 3 Mar 2019 20:47:09 +0200 Subject: [PATCH] Collector update --- Assets/Scripts/Collector.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Collector.cs b/Assets/Scripts/Collector.cs index 94e742b..3a1b448 100644 --- a/Assets/Scripts/Collector.cs +++ b/Assets/Scripts/Collector.cs @@ -140,16 +140,16 @@ public class Collector : MonoBehaviour { if (collision.gameObject.GetComponent<BoxCollider2D>().bounds.Contains(new Vector3(home.transform.position.x, home.transform.position.y, collision.gameObject.transform.position.z))) { - if (target.GetComponent<Outcrop>() && this.Requested_resource != null) + if (target != null && target.GetComponent<Outcrop>() && this.Requested_resource != null) { if(this.Requested_amount < this.max_amount) this.amount = home.GetComponent<City>().UseResource(this.Requested_resource, this.Requested_amount); else this.amount = home.GetComponent<City>().UseResource(this.Requested_resource, this.max_amount); } - else + else if (collision.gameObject.GetComponent<City>() != null) { - + //resets amount and resource variables collision.gameObject.GetComponent<City>().AddResource(this.resource, this.amount); this.amount = 0; -- GitLab