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
Share
Go down
Member [Lv. 2]
Member [Lv. 2]
Posts : 9
Points : 1426
Rep : 0
Join date : 2014-10-15
View user profile

The ball must jump only when it touches the ground

on Mon Dec 15, 2014 12:10 pm
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;
          }
      }
 
 
Member [Lv. 1]
Member [Lv. 1]
Posts : 3
Points : 1456
Rep : 0
Join date : 2014-08-18
View user profile

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

on Sun Dec 28, 2014 8:17 am
Use RaycastHit and distance
Back to top
Permissions in this forum:
You cannot reply to topics in this forum