示例#1
0
    // Use this for initialization
    void Start()
    {
        andscore old = FindObjectOfType <andscore> ();

        if (old)
        {
            score = old.score;
            Destroy(old.gameObject);
        }
    }
    void OnCollisionEnter(Collision collision)
    {
        andscore score = FindObjectOfType <andscore> ();

        score.IncrementScore(1);

        targetinst = Instantiate(targetPrefab);
        targetinst.transform.position = transform.position + new Vector3(Random.Range(-3.0f, 3.0f),
                                                                         Random.Range(-3.0f, 3.0f), Random.Range(2.0f, 2.5f));
        print(targetinst.transform.position);
        Destroy(gameObject);
    }