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

Collector update

parent 683fdd7a
Branches
No related tags found
No related merge requests found
......@@ -140,14 +140,14 @@ 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment