- Home /
 
               Question by 
               iasminaedina · Apr 01, 2014 at 04:18 PM · 
                javascriptmovementjumpsmooth  
              
 
              How to make smooth jump?
I have this mechanic where when you click the mouse anywhere on the screen, the character jumps in that direction. But the transition isn't smooth. How can i make it smooth?
Here is the code:
 var jumpDelay : boolean;
 var doubleJump : int = 0;
 private var ray : Ray;
 private var rayCastHit : RaycastHit;
 
 
 
     function Update()
        {
             if( Input.GetMouseButton(0) && jumpDelay == false)
        {
          Jump();                    
     }
 }
  
     function Jump()
        {
             if (doubleJump <= 1)
        {
             rigidbody.velocity.y = 8;
             
             ray = Camera.main.ScreenPointToRay (Input.mousePosition);
     if (Physics.Raycast (ray, rayCastHit))
 {
      transform.position.x = rayCastHit.point.x;
      transform.position.x = Mathf.Clamp (transform.position.x, -4, 4);}
                 jumpTimer();
     }
 }
  
     function jumpTimer()
        {
          if (Input.GetMouseButton(0))
        {
               doubleJump ++;
          }
  
               if (doubleJump > 1)
                {
                    doubleJump = 0;
                       jumpDelay = true;
                       yield WaitForSeconds(1);
                         jumpDelay = false;
            }
        }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
skigame movement problem 0 Answers
Move Object Smoothly 1 Answer
smooth movement 2 Answers
Camera movement(I have no clue how to code) 0 Answers
2D Character Jumps only 1 time 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                