예제 #1
0
    // doing this manually instead of the built in OnClick because of some bugs with the unity system
    void handleClickOn(Vector3 pos)
    {
        if (isPaused)
        {
            return;
        }

        Vector3 worldPos = Camera.main.ScreenToWorldPoint(pos);

        worldPos.z = 0;
        //GameObject.FindGameObjectWithTag("Player").transform.position = worldPos;
        RaycastHit2D hit = Physics2D.CircleCast(worldPos, 0.5f, Vector2.up, 0.1f);

        if (hit.collider != null)
        {
            Balloon balloon = hit.collider.GetComponent <Balloon>();
            if (balloon != null)
            { // check if object is actually a balloon
                balloon.BalloonClicked();
            }
        }
    }