Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Can't seem to get my Double Jump to work (Beginner)(2D)

Discussion in '2D' started by Centriax, Jul 6, 2020.

  1. Centriax

    Centriax

    Joined:
    Jul 2, 2020
    Posts:
    1
    Code (CSharp):
    1. //Jump Function
    2.        
    3.         void Jump()
    4.         {
    5.             rb2D.AddForce(Vector2.up * jumpPower);
    6.         }
    7.  
    8.         if(isGrounded == true)
    9.         {
    10.             doubleJumpCheck = true;
    11.         }
    12.  
    13.         if(isGrounded == true && Input.GetKey("space"))
    14.         {
    15.             Jump();
    16.         }
    17.         else if(doubleJumpCheck && Input.GetKey("space"))
    18.         {
    19.             Jump();
    20.             doubleJumpCheck = false;
    21.         }
    I can't seem to get the second jump to work
     
  2. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    535
    switch this


    Code (CSharp):
    1.   void Jump()
    2.         {
    3.             rb2D.AddForce(Vector2.up * jumpPower);
    4. isGrounded = false;
    5.         }
    6.