- Home /
How can I move left and right when jumpigng?
Hello I just make a simple game from Unity 3D tutorials and I want to control the player (ball) when I jumping. Sorry for my bad englis, I beginner in this, too:)
I made this script:
 #pragma strict
 
 var rotationSpeed = 100;
 var jumpHeight = 8;
 
 private var isFalling = false;
 
 function Update () 
 {
      //Handle ball rotation.
      var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
      rotation *= Time.deltaTime;
      rigidbody.AddRelativeTorque (Vector3.back * rotation);
      
      if (Input.GetKeyDown(KeyCode.W)  && isFalling == false)
      {
          rigidbody.velocity.y = jumpHeight;
      }
      isFalling = true;
     
 }
 
 function OnCollisionStay ()
 {
     isFalling = false;
 }
 
 
               Comment
              
 
               
              Answer by chrisall76 · Nov 30, 2013 at 09:02 PM
Add this to your code.
 if(isFalling == true){
     rigidbody.AddRelativeForce(new Vector3(Input.GetAxis("Horizontal") * airControl, 
                                Input.GetAxis("Vertical") * airControl));
 }
Your answer
 
 
             Follow this Question
Related Questions
Jump from position A to position B 2 Answers
How do you make an object go left and right? 1 Answer
How to Make an Endless Runner Move from track to track smoothly 0 Answers
Moving Right pressing left 1 Answer
endless runner game help 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                