コード例 #1
0
    void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.tag == "Ground")
        {
            // disable trail rendrer when ball is colliding with the ground
            this.gameObject.GetComponent <TrailRenderer>().enabled = false;
        }
        if (other.gameObject.tag == "Box")
        {
            if (!isCollide)
            {
                CannonController pressSpace = GameObject.FindObjectOfType <CannonController>();
                pressSpace.EnqueueBalls(this.gameObject);
                print(other.gameObject.name);
                isCollide = true;
            }
        }

        if (other.gameObject.tag == "Cylinder")
        {
            if (gameObject.tag == "Supercharged")
            {
                // update the score when supercharged ball hits with the cylinder
                ui_controllere.UpdateScore(5);
            }
            else
            {
                //Update the score when collide with cylinder
                ui_controllere.UpdateScore(1);
            }
        }
    }