using UnityEngine;
using System.Collections;

public class ChasePlayer : MonoBehaviour 
{
    public GameObject Player;
    public float Drive;

    Vector3 VectorToPlayer;
	
	void FixedUpdate () 
    {
        if (Player != null)
        {
            VectorToPlayer = Player.transform.position - this.transform.position;
            this.rigidbody.AddForce(VectorToPlayer.x * Drive, 0.0f, VectorToPlayer.z * Drive, ForceMode.Force);
        }
	}

    void OnCollisionStay(Collision argCollision)
    {
        if (Player != null && Player.name == "Character")
        {
            Destroy(argCollision.collider.gameObject);
        }
    }
}
