using UnityEngine;
using System.Collections;

public class DestroyBehind : MonoBehaviour {
	public float Limit=20;

	private Transform player;
	
	void Start () {	
		//GameObject pgo = GameObject.Find("Player");
		//player = pgo.transform;
	}
	
	void FixedUpdate () {
		if(player == null)
		{
			GameObject pgo = GameObject.Find("Player");
			if(pgo != null)
				player = pgo.transform;
		}
		else
		{
			if(player.position.y - transform.position.y > Limit)
				GameObject.Destroy(gameObject);
		}
	}
}
