Ejemplo n.º 1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        // Get the name of the collision's associated gameobject
        string name = collision.gameObject.name;

        if (name != "Eraser(Clone)")
        {
            return;
        }

        // Erase the SpeedBoost
        eraser.RemoveItem(gameObject);
    }
Ejemplo n.º 2
0
    // Update is called once per frame

    /*void Update () {
     *
     *  }*/


    private void OnTriggerEnter2D(Collider2D collision)
    {
        // Get the name of the collision's associated gameobject
        string name = collision.gameObject.name;

        if (name != "Ball" && name != "Eraser(Clone)")
        {
            return;
        }

        // Speed up the ball
        if (name == "Ball")
        {
            GetComponent <AudioSource>().Play();
            ball.GetComponent <Rigidbody2D>().AddForce(new Vector2(transform.right.x * boostAmt, transform.right.y * boostAmt));
        }
        else // Erase the SpeedBoost
        {
            eraser.RemoveItem(gameObject);
        }
    }