using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AI : MonoBehaviour {
    bool movingLeft = false;
    public float speed = 5.0f;

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		if (!movingLeft)
            if (transform.localPosition.x < 9)
            {
                transform.position = transform.position +
                    Vector3.right * speed * Time.deltaTime;
            }
            else movingLeft = true;

        if (movingLeft)
            if (transform.localPosition.x > -10)
            {
                transform.position = transform.position +
                    Vector3.left * speed * Time.deltaTime;
            }
            else movingLeft = false;
	}
}
