using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScaleWithDistanceToObject : MonoBehaviour {

	public Transform target;
	public Vector3 minScale;
	public Vector3 maxScale;
	public float maxDistance;
	public float minDistance;
	public bool printDebug;

	// Use this for initialization
	void Start () {
		if(target == null){
			target = GameObject.Find("PlutoPivot").transform;
		}
		maxDistance = transform.position.magnitude * 2f;
		 
	}
	
	// Update is called once per frame
	void Update () {
		if(printDebug)
			Debug.Log((target.position - transform.position).magnitude - minDistance);
		transform.localScale = Vector3.Lerp(minScale, maxScale, ((target.position - transform.position).magnitude - minDistance) / maxDistance);

	}
}
