Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » HELP » Help (General) » The ball must jump only when it touches the ground

The ball must jump only when it touches the ground

View previous topic View next topic Go down  Message [Page 1 of 1]

Radeon


Member [Lv. 2]
Member [Lv. 2]
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;
          }
      }
 
 

View user profile

websfera


Member [Lv. 1]
Member [Lv. 1]
Use RaycastHit and distance

View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum