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

Collector update

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