using UnityEngine;
using System.Collections;

public class Bala : MonoBehaviour {
	public float velocidade;
	
	void Start() {
		Invoke ("Destruir", 5f);
	}

	// Update is called once per frame
	void Update () {
		transform.Translate (0, 0, velocidade*Time.deltaTime);
	}

	void Destruir() {
		Destroy (this.gameObject);
	}

	void OnCollisionEnter(Collision c) {
		Debug.Log ("colidiu" + c.gameObject.tag);
		if (c.gameObject.tag == "inimigo") {
			Debug.Log ("com o inimigo");	
			c.gameObject.SendMessage ("Hit", 2);
				}
		else if(c.gameObject.tag != "jogador")
			Destroy (this.gameObject);
	}
}
