Skip to content
Snippets Groups Projects
Commit 83a2dac1 authored by Petteri's avatar Petteri
Browse files

Collector update

parent 44bda0c5
No related branches found
No related tags found
No related merge requests found
...@@ -78,7 +78,7 @@ public class Collector : MonoBehaviour ...@@ -78,7 +78,7 @@ public class Collector : MonoBehaviour
Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y); Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y);
RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero); RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero);
if (hit.collider != null) if (hit.collider != null && hit.collider.gameObject != null)
{ {
this.Requested_resource = null; this.Requested_resource = null;
...@@ -133,10 +133,13 @@ public class Collector : MonoBehaviour ...@@ -133,10 +133,13 @@ public class Collector : MonoBehaviour
} }
else else
{ {
//Amount of resources worker is carrying right now if(target != null)
this.amount = target.GetComponent<Resource>().extractResource(this.max_amount); {
//Gives target resource to resource variable //Amount of resources worker is carrying right now
this.resource = this.target.GetComponent<Resource>(); this.amount = target.GetComponent<Resource>().extractResource(this.max_amount);
//Gives target resource to resource variable
this.resource = this.target.GetComponent<Resource>();
}
StartCoroutine("goHome"); StartCoroutine("goHome");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment