FragMate CommunityLog in

FragMate - Software and Game Developer Community, including Resources, Forums, Marketplace & More.

Share

descriptionThe ball must jump only when it touches the ground

more_horiz
I want that the player ball must not jump when it is in the air , but only when the ball is on the ground How do I make jump the ball only when the ball touches the ground ?

--------------

Code:

var jumpDelay : boolean;
      var doubleJump : int = 0;
      function Update()
      {
          if(Input.GetKeyDown(KeyCode.Space) && jumpDelay == false)
          {
              Jump();
          }
      }
 
      function Jump()
      {
          if (doubleJump <= 1)
          {
              rigidbody.velocity.y = 10;
              jumpTimer();
          }
      }
 
      function jumpTimer()
      {
          if (Input.GetKeyDown(KeyCode.Space))
          {
              doubleJump ++;
          }
 
          if (doubleJump > 1)
          {
              doubleJump = 0;
              jumpDelay = true;
              yield WaitForSeconds(3);
              jumpDelay = false;
          }
      }
 
 

descriptionRe: The ball must jump only when it touches the ground

more_horiz
Use RaycastHit and distance
Permissions in this forum:
You cannot reply to topics in this forum