Exemplo n.º 1
0
    void Jump()
    {
        if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
        {
            isGrounded = false;
            rb.AddForce(transform.up * jumpSpeed);

            JumpAudio.Play();
        }
    }
Exemplo n.º 2
0
 void Jump()
 {
     if (isGround)
     {
         jumpCount = 2;
     }
     if (isJump && jumpCount > 0)
     {
         JumpAudio.Play();
         Body.velocity = new Vector2(Body.velocity.x, JumpForce);
         jumpCount--;
         isJump = false;
     }
 }
Exemplo n.º 3
0
 private void OnCollisionEnter(Collision collision)
 {
     IsGroundedUpate(collision, true);
     if (collision.gameObject.GetComponent <DeathTrigger>() != null)
     {
         GameOver();
         if (PlayerPrefs.GetString("music") == "Yes")
         {
             collision.gameObject.GetComponent <DeathTrigger>().PlayDeathSound();
         }
     }
     if (collision.gameObject.GetComponent <DecorCollision>() != null)
     {
         transform.DOMove(startPos, durationMove, false);
     }
     if (collision.gameObject.GetComponent <PlatformCollision>() != null)
     {
         if (PlayerPrefs.GetString("music") == "Yes")
         {
             JumpOnWoodAudio.Play();
         }
         transform.parent = collision.transform;
     }
     if (collision.gameObject.GetComponent <CoinCollision>() != null)
     {
         collision.gameObject.SetActive(false);
         LevelManager._LevelManager.SetCoins();
         if (PlayerPrefs.GetString("music") == "Yes")
         {
             CoinAudio.Play();
         }
     }
     if (collision.gameObject.GetComponent <GroundCollision>() != null)
     {
         if (PlayerPrefs.GetString("music") == "Yes")
         {
             JumpAudio.Play();
         }
     }
 }