// Update is called once per frame
    void Update()
    {
        GameObject spaceShip = GameObject.Find("spaceShip2");

        if (Vector3.Distance(spaceShip.transform.position, transform.position) < range)
        {
            spaceShipControl_single script = spaceShip.GetComponent <spaceShipControl_single>();
            script.removeLife();
            GameObject explosion = ((GameObject)Instantiate(Resources.Load("explosion"), transform.position, transform.rotation));
            explosion.transform.localScale = new Vector3(5, 5, 5);

            Destroy(explosion, 3f);
            //decrement ship life if is not undestroyable and add to center of tunel, set undestroyable for 3 seconds;
            Destroy(gameObject);
        }
    }
示例#2
0
    void OnTriggerEnter(Collider other)
    {
        Destroy(Instantiate(explosion, transform.position, transform.rotation), 2f);
        if (other.tag == "Player")
        {
            Destroy(Instantiate(playerExplosion, other.transform.position, other.transform.rotation), 2f);
        }
        Destroy(gameObject);
        if (other.name == "spaceShip2")
        {
            spaceShipControl_single script = other.GetComponent <spaceShipControl_single>();
            script.removeLife();
            return;
        }
        Destroy(other.gameObject);

        counter++;
        GameObject.Find("dataTransfer").GetComponent <dataTransfer> ().data = counter;
        TextMesh score = GameObject.Find("Score").GetComponent <TextMesh> ();

        score.text = counter.ToString();
    }