您的位置:首页 > 移动开发 > Unity3D

unity之怪物生出

2015-01-17 23:09 106 查看
public GameObject mouse;//声明老鼠

    public GameObject gold;//声明金币

    public GameObject HP;//声明血瓶

    int i = 9;

    void start()

    {

        mouse = GameObject.FindGameObjectWithTag("mouse");

    }

    void Update()

    {

    }

    void OnTriggerEnter(Collider other)

    {

        if (other.tag == "mouse")

        {

            Slave.life--;

            print(Slave.life);

           

            if (Slave.life == 0)

            {

                Player.experience += 5;

                Destroy(other.gameObject ,1.2f);

               GameObject go= Instantiate(mouse, new Vector3(Random.Range(54, 72), 0.8677917f, Random.Range(78, 90)), Quaternion.identity) as GameObject ;

               Instantiate(gold, other.gameObject.transform.position+new Vector3 (0,0,2), Quaternion.identity);//掉落金币

               Instantiate(HP, other.gameObject.transform.position+new Vector3 (2,0,0), Quaternion.identity);//掉落血瓶

                Slave.life = 10;

            }

        }

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息