Example #1
0
    // Update is called once per frame
    void Update()
    {
        playerFound = player.IsPlayerFound();

        if (GameControl.instance.totalTimePassed > 2.5)
        {
            rb2d.gravityScale = birdGravity;
            if (isDead == false && playerFound)
            {
                if (!canFlap && player.GetLeftHandY() > player.GetHeadY() && player.GetRightHandY() > player.GetHeadY())
                {
                    canFlap = true;
                }

                if (Input.GetMouseButtonDown(0) || (canFlap && (player.GetLeftHandY() < player.GetHipY() && player.GetRightHandY() < player.GetHipY())))
                {
                    birdFlap.Play();
                    rb2d.velocity = Vector2.zero;
                    rb2d.AddForce(new Vector2(0, upforce));
                    anim.SetTrigger("FlapParam");
                    canFlap = false;
                }
            }
        }
    }