private void FixedUpdate()
    {
        //Checks if the player pressed the jump button before applying the jump
        if (jumped || doubleJumped)
        {
            jump();
            numberOfJumps--;
            jumped = false;

            if (doubleJumped)
            {
                doubleJumped = false;
            }
        }

        if (status.getTechyBounce())
        {
            techyBounce();
            status.setTechyBounce(false);
        }

        //Increases gravity when player is falling. Also accounts for when the player only holds jump for a short time
        if (rb.velocity.y < 0)
        {
            rb.velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime;
        }
        else if (rb.velocity.y > 0 && !Input.GetButton("Jump"))
        {
            rb.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime;
        }
    }
Esempio n. 2
0
    void FixedUpdate()
    {
        if (pounding)
        {
            if (hangtime)
            {
                currentHangtime += Time.deltaTime;

                if (currentHangtime < maxHangTime)
                {
                    GetComponent <Rigidbody2D>().velocity = new Vector2(GetComponent <Rigidbody2D>().velocity.x, 3.0f);
                }
                else
                {
                    hangtime        = false;
                    currentHangtime = 0;
                }
            }

            if (!hangtime)
            {
                GetComponent <Rigidbody2D>().velocity = new Vector2(0, dropSpeed);
            }
        }

        if (status.getGrounded() || status.getTechyBounce())
        {
            pounding = false;
            status.setPounding(false);
            anim.SetBool("Pounding", pounding);
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (status.getPounding())
     {
         gameObject.GetComponent <BoxCollider2D>().enabled = true;
         //box.enabled = true;
     }
     else if (status.getTechyBounce() || status.getGrounded())
     {
         gameObject.GetComponent <BoxCollider2D>().enabled = false;
         //box.enabled = false;
     }
 }