using UnityEngine;
using System.Collections;

public class movePrefab : MonoBehaviour {

    public float speed;

	// Use this for initialization
	void Start () {
        Invoke("DestroyOnTime", 5f);
	}
	
	// Update is called once per frame
	void Update () {
        gameObject.transform.position += Vector3.forward * 1 * speed;
	}
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            other.GetComponent<Rigidbody>().velocity = new Vector3(0, 5, 20);
            Destroy(gameObject);
        }

        if (other.gameObject.tag == "Backwall")
        {
            Destroy(gameObject);
        }
        if (other.gameObject.tag == "Bass")
        {
            other.GetComponent<Rigidbody>().velocity = new Vector3(0, 5, 5);
        }
    }
    void DestroyOnTime() {
        Destroy(gameObject);
    }
}
