
public var target:Transform;
public var index:int;

function Start(){
               
			   if(!target){
			   target = gameObject.Find("player").transform;			   
               }


}

function Update () {
var oldDistance:float;
               
			   
			   
               var difference = target.position-transform.position;
			   var distance=difference.magnitude;
               if(distance >= 1.5 ){ 

			   // if(distance != oldDistance){
			   var targetDirection = difference.normalized;           
				
               transform.Translate(targetDirection * Time.deltaTime*8.0);
                //oldDistance = distance;
			//	}
               }
			
			   transform.position.x += Time.deltaTime*playerScript.playerConstSpeed;


}