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

public class MoveObjeto : MonoBehaviour {

	public float speed;
	private float x;
	public GameObject Player;
	private bool pontuado;

	// Use this for initialization
	void Start () {
		Player = GameObject.Find ("Prancheta 1") as GameObject;
	}
	
	// Update is called once per frame
	void Update () {

		x = transform.position.x;
		x -= speed * Time.deltaTime;

		transform.position = new Vector3 (x, transform.position.y, transform.position.z);

		if( x <= -8.88){
			Destroy (transform.gameObject);
		}

		if (x < Player.transform.position.x && !pontuado) {
			pontuado = true;
			Controller.pontuacao++;
		}
	}
}
