using UnityEngine;
using System.Collections;

public class EnemyScript : MonoBehaviour {

    public float speed;
    public Transform respawnPoint;
    private GameObject gameWorld;
    public GameObject enemyStart;

	// Use this for initialization
	void Start () {
        gameWorld = GameObject.Find("GameWorld");
        transform.position = enemyStart.transform.position;
	}
	
	// Update is called once per frame
	void Update () {
        Vector3 translation = new Vector3(Time.deltaTime * speed, 0);
        transform.Translate(translation);
	}

    void OnTriggerEnter(Collider other)
    {
        Debug.Log("ENEMY ON TRIGGER ENTER");
        //other.transform.position = respawnPoint.transform.position;
        gameWorld.SendMessage("ReturnToStart");
        transform.position = enemyStart.transform.position;
    }

}
