using UnityEngine;
using System.Collections;

public class TargetedMover : MonoBehaviour
{
	public float Speed;
	public float Randomization;
	float speed;

	Transform target;
	Transform thisTransform;

	void Start()
	{
		speed = Speed + Random.Range(0, Randomization);

		target = GameObject.FindGameObjectWithTag("Player").transform;
		thisTransform = transform;
	}

	void Update ()
	{
		Vector2 targetVector = (target.position - thisTransform.position);
		targetVector = targetVector.normalized * (speed * Time.deltaTime);
		rigidbody2D.MovePosition((Vector2)thisTransform.position + targetVector);
	}
}
