#pragma strict

public var ySmooth : float;
public var yMargin : float;
public var player : GameObject;

function Start () {

}

function CheckYMargin () {

	return Mathf.Abs(transform.position.y - player.transform.position.y) > yMargin;

}

function FixedUpdate () {

	if (player) {
		TrackPlayer();
	}
}

function TrackPlayer () {

	var targetY : float = transform.position.y;

	if (CheckYMargin())
	{
		targetY = Mathf.Lerp(transform.position.y, player.transform.position.y, ySmooth * Time.deltaTime);
	}
	
	transform.position = new Vector3(5, targetY, transform.position.z);

}