Пример #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject      lifeobj    = GameObject.Find("Canvas");
        scorecontroller lifescript = lifeobj.GetComponent <scorecontroller>();



        GameObject shipobj    = GameObject.Find("Canvas");
        moveship   shipscript = shipobj.GetComponent <moveship>();

        if (collision.gameObject.tag == "asteroid")
        {
            shipscript.ship.velocity                 = Vector3.zero;
            shipscript.ship.angularVelocity          = 0;
            shipscript.shipobject.transform.position = new Vector3(0, 0, 0);
            Destroy(collision.gameObject);
            lifescript.lives -= 1;
        }

        if (collision.gameObject.tag == "powerup")
        {
            shipscript.ship.angularVelocity = 0;
        }

        if (collision.gameObject.tag == "comet")
        {
            shipscript.ship.velocity                 = Vector3.zero;
            shipscript.ship.angularVelocity          = 0;
            shipscript.shipobject.transform.position = new Vector3(0, 0, 0);
            Destroy(collision.gameObject);
            lifescript.lives -= 1;
        }
    }
Пример #2
0
 public void SpawnPrefab()
 {
     moveship ship = GetComponent <moveship>();
     // bulletinstance = Instantiate(bullets, ship.ship.transform.position, Quaternion.identity);
 }