using UnityEngine;
using System.Collections;

public class walk : MonoBehaviour {
	public Transform distancia;
	Botao inter;
	public GameObject cube;

	// Use this for initialization
	void Start() {
		inter = cube.GetComponent<Botao> ();

	}
	
	// Update is called once per frame
	void Update(){
						if (inter.caminho == false) {
								transform.Translate (0.05f, 0, 0);
			if(transform.position.x > -16){
				transform.eulerAngles = new Vector3(0f,180f,0f);
			}
			if(transform.position.x < -9){
				transform.eulerAngles = new Vector3(0f,0f,0f);
			}
						}
						if (inter.caminho == true) {
								transform.Translate (0, 0, 0.1f);
								if (transform.position.z > 24f) {
										transform.eulerAngles = new Vector3 (0, 180, 0);
								}
								if (transform.position.z < 15f) {
										transform.eulerAngles = new Vector3 (0, 0, 0);
								}
						}

				}
void OnTriggerEnter(Collider other){
	if (other.collider.tag == "Player") 
	{
	distancia.position = new Vector3(671f, -21.6f,-331.6f);
	}
	}
	
	}


	
	

